Java
-
String vs StringBuffer개발하면서/etc 2009. 4. 17. 14:31
String str = new String ("Stanford "); str += "Lost!!"; 바이트 코드로 변환하면 아래와 같다. 0 new #7 3 dup 4 ldc #2 6 invokespecial #12 9 astore_1 10 new #8 13 dup 14 aload_1 15 invokestatic #23 18 invokespecial #13 21 ldc #1 23 invokevirtual #15 26 invokevirtual #22 29 astore_1 String '+'연산을 할때 임시저장소 StringBuffer을 만든뒤 append를 한 후 다시 String으로 변환하는 작업을 한다. 바이트 코드로 변환하면 다음과 같다 StringBuffer str = new StringBuffer..