package i_api;
public class Stringspeedtezt {
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");//끝 - 시작 = 걸린 시간 구하기
// String은 문자열을 만들때 새로운 객체가 생김 -> string말고 다른것 사용하기
}
}