日期:2014-05-20 浏览次数:20864 次
import java.util.Date; public class Test { public static void main(String[] args) { int times = 200000; long l1=new Date().getTime(); StringBuffer c = new StringBuffer("ccc"); for (int i = 0; i < times; i++) { c.append("ccc"); } long l2=new Date().getTime(); System.out.println(l2-l1); times=1000000; for (int i = 0; i < times; i++) { c.append("ccc"); } long l3=new Date().getTime(); System.out.println(l3-l2); } }