• Post Reply Bookmark Topic Watch Topic
  • New Topic

printing statement  RSS feed

 
Arun Prasath
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String s=new String("hi");
String o="hi";
System.out.println(s.equals(o)+" "+s==o);

the above code prints only "false". It is supposed to print "true false".
-------------
String s=new String("hi");
String o="hi";
System.out.println((s.equals(o))+" "+(s==o));
but this code(after giving bracktes), it prints "true false"

what is happeining here?
 
Jan-Jaap van Nieuwkerk
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun,

If i am correct it all has to do with precedence
I guess the answer in this thread applies here too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!