String当中的intern()

Posted wgdream

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了String当中的intern()相关的知识,希望对你有一定的参考价值。

 

public class String001 {
	public static void main(String[] args) {
		String s1 = "hello";
		String s2 = new String("hello");
		String s3 = new String("hello").intern();
		
		System.out.println(s1 == s2); //false
		System.out.println(s1 == s3); //true	
	}
}

  

技术图片

 

以上是关于String当中的intern()的主要内容,如果未能解决你的问题,请参考以下文章