A a1 = new A();a1.setName("wang");A a2 = new A(); long b = new java.util.Date().getTime();a2.setName(a1.getName());long e = new java.util.Date().getTime(); System.out.println("time1="+(e-b));A a3 = new A();b = new java.util.Date().getTime();PropertyUtils.copyProperties(a3, a1);e = new java.util.Date().getTime();System.out.println("time2="+(e-b));
输出结果time1的时间比time2的时间小,用PropertyUtils、BeanUtils时间差不多。PropertyUtils支持不同类型相同变量名的拷贝,它会自动转换数据类型