• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Wrapper Class

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a Question from Danch

According to me the Output should be:false,true,true.becoz valueOf();
method is just another way to construct wrapper object,and when we compare
two different object references it returns false.While the idea i have got
from the explanation of Question is their is a huge difference between
saying:
But Still the thing left dangling is,is'nt both the objects are different.
plz elobrate on to this as soon as possible.

Thanks
Java Man
Deshdeep
 
deshdeep divakar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
All Ranchers have a close look to this code

Output:
false,true
false,true
true,true,true
whether according to me
Output:
false,true
false,true
false ,true,true
which is coz we r comparing two different object references via ==
plz elobrate to this...
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Bolleans true and false are stored in literal pools...so there will be only two values...that never get change. and references are pointing to these values only..Depends on the value,it will point to either false or true..so the results...


Thanks
Pari
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic