| Author |
Strings
|
Rajani Sudhakar
Ranch Hand
Joined: Apr 28, 2004
Posts: 60
|
|
Read this piece of code carefully __________________________________________________________ if("String".replace('g','G') == "String".replace('g','G')) System.out.println("Equal"); else System.out.println("Not Equal"); ___________________________________________________________ Answers 1.the code will compile an print "Equal". 2.the code will compile an print "Not Equal". 3.the code will cause a compiler error Correct Answer : 2.the code will compile and print "Not Equal" But the result String formed on the lefthand side and that of the righthand side seem to be equal.. Can anyone justify the correct answer? Thanks in advance, rajani.
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
Compare the output from that code with this: Did you figure it out yet? If not, check this out, as well.
|
SCJP Tipline, etc.
|
 |
 |
|
|
subject: Strings
|
|
|