mohamed sanaullah wrote:Its always ideal to search in the forum first. And Agree with Jesper that this is the most commonly asked question.
To the JavaRanch Team: Why not have a FAQ on this? Or is there one already?
Hey i searched but bingo..i didn't find it jesper and mohamed,
i didn't get it, do you mean to say when i say:-
String s = "Computer";
and if(s=="Computer")
its going to match s(address) with the string "Computer"???
then why does it just print "Equals B" as when i do :-
String s = new String("Computer");
if(s=="Computer"){
System.out.println("Equals A");
}
if(s.equals("Computer"))
{
System.out.println("Equals B");
}
the output comes "Equals B",
just can't get the difference that the way of declaration is making??