Among the 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	
	}
}

  

 

Guess you like

Origin www.cnblogs.com/wgDream/p/12038770.html