欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java String之迷惑

程序员文章站 2022-06-06 09:46:07
...
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
}
}
相关标签: String 老A