• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic doubt regarding ==

 
Pandharinath Barve
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer i = 127;
Integer j = 127;
if (i == j){
System.out.println("Same");
}
else{
System.out.println("different");
}
output = same.

Integer i = 128
Integer j = 128;
if (i == j){
System.out.println("Same");
}
else{
System.out.println("different");
}
output = different.

Please explain why ?
 
Srinivas Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question is already repeated in the forum.
please see the link
http://www.coderanch.com/t/262155/java-programmer-SCJP/certification/equals
 
Pandharinath Barve
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please explain me in detail..
 
Pandharinath Barve
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it, thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic