• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Doubt in Boxin equals() and ==

 
Ranch Hand
Posts: 41
Mac OS X Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Doubt on behavior of !=, == and equals method in following example from K&B. please some one explain little bit more about that. sorry for such stupid question.


Thanks In Advance.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jeetendra Choudhary wrote:I have Doubt on behavior of !=, == and equals method in following example from K&B. please some one explain little bit more about that. sorry for such stupid question.


Thanks In Advance.



The output is:
Different Object
Meaningfuly Equal
Same object
Meaningfuly Equal

I am just a human compilator

If we perform == on Integer, Short and Byte wrapper objects whose boxing value is from interval (-128; 127), the operator returns true. Very important is that those values must be AUTOboxed. If we would create them using operator new, we were given false by ==. new always allocates new space in memory.

This question was answered a couple of times, so read the forum carefully, please

 
jeetendra Choudhary
Ranch Hand
Posts: 41
Mac OS X Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also suggest me practice questions objective wise so i can solve to revise the previous objectives learned. Have played the rules roundup game lots of time it helped me very very much and thanks alot for that. but it still lacks questions for 1.6. please suggest me objective wise questions.
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic