9 Replies Latest reply: Feb 3, 2014 5:28 PM by jschellSomeoneStoleMyAlias RSS

String reference equality

Prem Newbie
Currently Being Moderated

I don't understand why following code when executed returns false

 

String s1= " string".trim();
  if(s1 == "string"){
  System.out.println("true");
  }
  else{
  System.out.println("false");
  }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points