碰到的有意思的代码
Posted season1992
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了碰到的有意思的代码相关的知识,希望对你有一定的参考价值。
public static void main(String[] args) { String a1 = new String("a_a"); String a2 = new String("a_a"); System.out.println("a:"); System.out.println(a1 == a2); System.out.println("-------------------------"); String b1 = "b_b"; String b2 = "b_b"; System.out.println("b:"); System.out.println(b1 == b2); System.out.println("-------------------------"); String c = new String("c"); String c1 = c + "_c"; String c2 = "c_c"; System.out.println("c:"); System.out.println(c1 == c1.intern()); System.out.println(c1 == c2); System.out.println(c2 == c1.intern()); System.out.println(c2 == c2.intern()); System.out.println("-------------------------"); String d = new String("d"); String d1 = d + "_d"; System.out.println(d1 == d1.intern()); String d2 = "d_d"; System.out.println("d:"); System.out.println(d1 == d2); System.out.println("-------------------------"); }
以上是关于碰到的有意思的代码的主要内容,如果未能解决你的问题,请参考以下文章