Java String之迷惑
程序员文章站
2022-06-06 09:33:48
...
package com.bobo;
public class Test {
/**
* @param args
*/
public final String a;
public final String a1 = "a";
public Test() {
a = "a";
}
public static void main(String[] args) {
new Test().testA();
}
public void testA() {
String b = a + "b";
String b1 = a1 + "b";
String c = "ab";
System.out.println(c == b);//false
System.out.println(c == b1);//true
}
}
public class Test {
/**
* @param args
*/
public final String a;
public final String a1 = "a";
public Test() {
a = "a";
}
public static void main(String[] args) {
new Test().testA();
}
public void testA() {
String b = a + "b";
String b1 = a1 + "b";
String c = "ab";
System.out.println(c == b);//false
System.out.println(c == b1);//true
}
}
上一篇: 男人出轨的表现 如何挽回出轨的男人?
下一篇: 女人婚姻不幸的原因有六点