반응형
public class Tuning {
public static void main(String[] args) {
// 1.
String s = new String();
long start = System.currentTimeMillis();
long stop = 0;
for(int i =0 ; i < 10000 ; i++){
s += "a";
stop = System.currentTimeMillis();
}
System.out.println("String : "+(stop - start)+"초");
// 2.
StringBuffer sb = new StringBuffer();
long start2 = System.currentTimeMillis();
long stop2 = 0;
for(int i =0 ; i < 10000 ; i++){
sb.append("a");
stop2 = System.currentTimeMillis();
}
System.out.println("String : "+(stop2 - start2)+"초");
}
}