Java??????????????
???????????? ???????[ 2016/2/24 15:46:57 ] ??????????????? ???????????
?????.??????
???????????
??????final???ε??????????????????????????????
????final???ε????????????????????????????????????????????????????????
????Class????е??????
??????Class??????У????4?????????洢???Magic Number?????????????????????JVM??????????4?????????洢?汾????2?????洢??汾?????2???洢???汾????????????????????????????????????????????????????????????????????U2?????????(constant_pool_count)?洢?????????????????
???????????????????????????????????(Literal)???????????(Symbolic References)????????????Java??????泣????????????????????????final????????????????????????????????????????????????????????????
????????????????
??????????????????
???????????????????
???????????е????????????
??????????????????????????????
????CLass????г????????汾????Ρ???????????????????????????????????????????????????????????????????????????????????????????????????????????????д???
????????????????????CLass??????????????????????????????????Java?????????????????б????????????????????????CLass????г??????????????????????????????????????????????μ??????????У???????????????????????????String???intern()??????
?????????????
???????????????????????????????????????????????????????????????
???????????????????????????????е??????????????????????С?
??????1?????????????????????????????????????????????????????
??????2???????????????????????==??equals()??????????????????????==?ж??????????????????ж????????????
????????==?????
???????????????????????????????????????????
????????????????(??)???????????????????????????е???????
??????.8????????????????????
????java?л??????????????????????????????????Byte??Short??Integer??Long??Character??Boolean??
????Integer i1 = 40;
????Integer i2 = 40;
????System.out.println(i1==i2);//???TRUE
??????5?????????????????[-128??127]????????????????????????????Χ???????????μ????
????//Integer ??????? ??
????public static Integer valueOf(int i) {
????assert IntegerCache.high >= 127;
????if (i >= IntegerCache.low && i <= IntegerCache.high)
????return IntegerCache.cache[i + (-IntegerCache.low)];
????return new Integer(i);
????}
????Integer i1 = 400;
????Integer i2 = 400;
????System.out.println(i1==i2);//???false
??????????????????????Float??Double??????????????????
????Double i1=1.2;
????Double i2=1.2;
????System.out.println(i1==i2);//???false
??????ó?????????
????(1)Integer i1=40??Java??????????????????????Integer i1=Integer.valueOf(40);???????ó??????е????
????(2)Integer i1 = new Integer(40);?????????????μ????
????Integer i1 = 40;
????Integer i2 = new Integer(40);
????System.out.println(i1==i2);//???false
????Integer???????????????
????Integer i1 = 40;
????Integer i2 = 40;
????Integer i3 = 0;
????Integer i4 = new Integer(40);
????Integer i5 = new Integer(40);
????Integer i6 = new Integer(0);
????System.out.println("i1=i2 " + (i1 == i2));
????System.out.println("i1=i2+i3 " + (i1 == i2 + i3));
????System.out.println("i1=i4 " + (i1 == i4));
????System.out.println("i4=i5 " + (i4 == i5));
????System.out.println("i4=i5+i6 " + (i4 == i5 + i6));
????System.out.println("40=i5+i6 " + (40 == i5 + i6));
????i1=i2 true
????i1=i2+i3 true
????i1=i4 false
????i4=i5 false
????i4=i5+i6 true
????40=i5+i6 true
????????????i4 == i5 + i6?????+?????????????????Integer????????i5??i6?????????????????????????????i4 == 40?????Integer??????????????????????????i4?????????int?40?????????????40 == 40???????????
??????.String????????
????String?????????
????String str1 = "abcd";
????String str2 = new String("abcd");
????System.out.println(str1==str2);//false
????????????????????????в?????????????????????????????????????????????????????μ????
?????????new????????????????μ????
??????????? +
??????1????????????????????????????String??????????“+”????????????????????????????С?
??????2?????????а???new??????????????null????“+”????????????????????????????????????????С?
????String str1 = "str";
????String str2 = "ing";
????String str3 = "str" + "ing";
????String str4 = str1 + str2;
????System.out.println(str3 == str4);//false
????String str5 = "string";
????System.out.println(str3 == str5);//true
????????1
????public static final String A = "ab"; // ????A
????public static final String B = "cd"; // ????B
????public static void main(String[] args) {
????String s = A + B; // ????????????+?????s???г????
????String t = "abcd";
????if (s == t) {
????System.out.println("s????t????????????????");
????} else {
????System.out.println("s??????t?????????????????");
????}
????}
????s????t????????????????
????A??B????????????????????s?????????????????????????????????????String s=A+B; ??????String s=”ab”+”cd”;
????????2
????public static final String A; // ????A
????public static final String B; // ????B
????static {
????A = "ab";
????B = "cd";
????}
????public static void main(String[] args) {
????// ????????????+?????s???г????
????String s = A + B;
????String t = "abcd";
????if (s == t) {
????System.out.println("s????t????????????????");
????} else {
????System.out.println("s??????t?????????????????");
????}
????}
????s??????t?????????????????
??????
???·???
??????????????????
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