그거/Java
String.intern() 메소드
뽀기
2011. 5. 2. 19:41
String.intern( ) returns the String object that is being stored in the internal VM string pool. If two Strings are equal, then their
intern( ) results are identical; for example, if s1.equals(s2) is true, then s1.intern( ) == s2.intern( ) is
also true.
String.intern() 메소드는 VM 내부의 String pool 에서의 String 객체를 반환한다.
두 String 객체의 내용이 같다면 intern() 메소도가 반환하는 값도 같다.
즉,
s1.equals(s2) == true 는 s1.intern() == s2.intern()
이다.