KingShawn / Blog

【 技术博客 】
3 stars 2 forks source link

JAVA中的字符串String拼接问题的思考 #7

Open KingShawn opened 7 years ago

KingShawn commented 7 years ago
public static void main(String[] args) {
    String a = "hello";
    String b = "world";
    String c = "helloworld";
    final String d = "world";
    String e = a + b;
    String f = a + "world";
    String g = "hello" + "world";
    String h = "hello" + d;
    System.out.println(c == e);
    System.out.println(c == f);
    System.out.println(c == g);
    System.out.println(c == h);
}