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");

	}

}

'CODE > JAVA1' 카테고리의 다른 글

ClassMaker  (0) 2021.01.27
test  (0) 2021.01.27
StringClass  (0) 2021.01.27
Sort  (0) 2021.01.27
SetComma  (0) 2021.01.27