• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt regarding the operator ==  RSS feed

 
Diego Virgüez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

It is my first post  . I'm studying for the ocajp 8 and a i have a question:  I'm studying regarding the operator == and i was doing some test whit the following code:



When I check the output, I realize that s1==s3 is false and s2==s3 too. Can someone tell me why s1==2 it is true and s1==s3 it is false ?

Thank you.
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know the String Constant (or Literal) Pool?

This excellent article about strings and literals is definitely a must-read!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!