| Author |
wrapper class?
|
srikanth reddy
Ranch Hand
Joined: Jul 28, 2005
Posts: 252
|
|
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 ]
|
Thanks & Regards<br /> <br />-Srikanth
|
 |
Lalitha Gottumukkula
Ranch Hand
Joined: May 24, 2005
Posts: 45
|
|
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.
|
 |
Michael Ernest
High Plains Drifter
Sheriff
Joined: Oct 25, 2000
Posts: 7292
|
|
Maybe this will help: Regards,
|
Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
|
 |
agrah upadhyay
Ranch Hand
Joined: Sep 01, 2005
Posts: 579
|
|
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 ]
|
<i>--Agrah Upadhyay--</i><br />Final Year B.Tech SCJP,SCWCD,SCBCD <br /> <br /><b>Now since the real test for any choice is having to make the same choice again,knowing full well what it might cost.</b>-Oracle
|
 |
agrah upadhyay
Ranch Hand
Joined: Sep 01, 2005
Posts: 579
|
|
Haa Haa Haa With above posting i have completed my 101 posts
|
 |
Arvind Giri
Ranch Hand
Joined: Jun 26, 2005
Posts: 91
|
|
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.
|
Regards<br /> <br />Arvind Giri<br />MCA,SCJP 1.4,SCWCD 1.4<br />Looking for SCDJWS
|
 |
 |
|
|
subject: wrapper class?
|
|
|