| Author |
Strings
|
jose chiramal
Ranch Hand
Joined: Feb 12, 2010
Posts: 266
|
|
Output :
HelloequalsHellotrue
Hello==Hellotrue
Hello==Hellotrue
value of s1Hello
value of s2Hello
value of s1Hello
value of s2null // how ??? arent s1 and s2 pointing to the same location ?
Hello==nullfalse // how ???
|
 |
Pramod P Deore
Ranch Hand
Joined: Jul 15, 2008
Posts: 629
|
|
|
sorry I post this in wrong forum
|
Life is easy because we write the source code.....
|
 |
Pramod P Deore
Ranch Hand
Joined: Jul 15, 2008
Posts: 629
|
|
You have assigned null to s2 at line 15. It does not affect s1
|
 |
Yogesh Gnanapraksam
Ranch Hand
Joined: Dec 17, 2009
Posts: 133
|
|
Are you expecting a null pointer exception in this line ?
s1 == s2
It is other way of checking whether a string is null
if (s1==null) --> false
it works as expected....
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
jose chiramal wrote:value of s2null // how ??? arent s1 and s2 pointing to the same location ?
Well, not anymore. You let s2 point to a different location, to be precise no location at all.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
jose chiramal
Ranch Hand
Joined: Feb 12, 2010
Posts: 266
|
|
I have a similar question below
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
Yes, of course null is a different location.
|
 |
 |
|
|
subject: Strings
|
|
|