I'm reading a Java magazine and the autor use the intern() method to compare Strings.
String ns;
String erg; 
if( ns != erg.intern() ) {
    System.out.println("is not equals");
}
I never heard about this method. I'm always using equals instead.
if( !ns.equals(erg) ) {
    System.out.println("is not equals");
}
When should I use intern() and when equals? or are they the same?
 
    