• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

== operator doubt?

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does and what happend when we try 5 == 5?? with a java 1.4 version?? I tried with 1.5 and it gave me true as the o/p.

Anyone here to explain this?
 
Ignacio Cavero
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's going to happen the same thing in java 1.4 or 1.5, java is designed to be backwards compatible. In both cases the == compares if the primitives have the same value, or if the references both point to the same instances of the object (to know if two different instances both represent the same object you must override and use the .equals method defined in Object)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic