Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
public class GoodComparison {
  public static void main(String[] args) {
    String one = new String("one");
    String two = new String("one");
    boolean result;
    if (one == null){
    	  result = two == null;
    }
    else{
     	 result = one == two || one.equals(two);
    }
   System.out.println(result);
  }
}

...

Code Block
bgColor#ccccff
public class GoodComparison {
  public static void main(String[] args) {
    String one = new String("one");
    String two = new String("one");
    boolean result;
    if (one != null){
     	 one = one.intern();
    }
    if (two != null){
     	 two = two.intern();
    }
    result = one == two;

   System.out.println(result);
  }
}

...