CODE/JAVA1
StringSpeedTest
maskan
2021. 1. 27. 15:53
public class StringSpeedTest {
public static void main(String[] args) {
// String str = "a";
// long start = System.currentTimeMillis();
// for(int i = 0; i<200000; i++){
// str+="a";
// }
//
// long end = System.currentTimeMillis();
// System.out.println(end-start + "ms");
// }
StringBuffer sb = new StringBuffer("a");
long start = System.currentTimeMillis();
for (int i = 0; i < 200000; i++) {
sb.append("a");
}
long end = System.currentTimeMillis();
System.out.println(end - start + "ms");
}
}