• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

wrapper class?

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

here the Output iam getting is "b1.toString()"...here we have only one reference value ..what are we doing here by calling toString method...
can anyone help me???

thanks

srikanth
[ September 28, 2005: Message edited by: Michael Ernest ]
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think if(b1.toString() == b1.toString()) is trying to compare two different String objects, not their values. b1.toString() returns a string equivalent of object b1.

Try to use if(b1.toString().equals(b1.toString()). This will compare values in the objects.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe this will help:

Regards,
 
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Here on calling b.toString() in b1.toString() == b1.toString() we get two different String object because call to toString() is
done at run time.so == should result in false.Please correct me iff i am wrong
[ September 28, 2005: Message edited by: agrah upadhyay ]
 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Haa Haa Haa
With above posting i have completed my 101 posts
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes! you are using only one reference b;
However keep in mind b.toString() returns a new String object, everytime it has been called.
That is why the actual checking here is between the reference returned by two b.toString(), which are different.
reply
    Bookmark Topic Watch Topic
  • New Topic