???JVM??????6??????
???????????? ???????[ 2013/4/2 9:25:31 ] ????????
?????? ????????MethodArea??
???????????????????????????????????????η?????????е????????????ж????final?????????????е?Field????????е????????????????????????????Class?????е?getName??isInterface??????????????????Щ??????????????????????????????????????????????????????????????????????????????????????????GC?????????????????????泬??????????С????????OutOfMemory??????????
??????Sun JDK??????????????PermanetGeneration????????????????64M???????-XX??PermSize???-XX??MaxPermSize????????С??
?????? ????????????RuntimeConstant Pool??
????????C?е??????????????е???????????????????Field?????????????????????????з????????????????????class?????java????????????????
?????? ????????????NativeMethod Stacks??
????JVM??????????????????native????????У???????????洢???native?????????????
???????????????δ???
public class A {
public static void main(String[]args){
String a="a";
String b="b";
String ab="ab";
System.out.println((a+b)==ab); // false
System.out.println(("a"+"b")==ab); // true
final String afinal="a";
String result=afinal+"b";
System.out.println(result==ab); // true
String plus=a+"b";
System.out.println(plus==ab); // false
System.out.println(plus.intern()==ab); // true
}
}
???????????????????е??????????javap –verbose A??????????????
?????? (a+b)==ab
????a+b?????????????????????????????????????????????JVM??????????????????μ???????a+b==ab?????false??
?????? (“a”+”b”)==ab
????“a”+”b”?????????????JVM?????????”ab”??????????ab=”ab”?????????????????????????????????(“a”+”b”)==ab?true??
?????? result==ab
????result=afinal+”b”??afinal???final??????? result??????????????????”ab”????”ab”???????????????????????result==ab?true??
?????? plus=ab
????plus??a+b????????????????plus==ab?false??
?????? plus.intern()==ab
??????????????????????plus.intern()???????????????????????plus????????????????plus.intern()==ab?true??
????????????JVM?????????????????????????JVM???????????????????????????????????Heap???Method Area?????????????????????????JVM??????????????????й????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11