Originally posted by venkataramana ramana:
I have a pice of code:
class StringExample
{
public static void main(String[] args)
{
String s ="Hello";
String t = s.toLowerCase();
String u = s.toLowerCase();
if( t == u)
System.out.println("equals");
else
System.out.println("false");
}
}
In this code string obj 't' and 'u' are created using 's' obj
but it prints false
i can't under stand why like that?
I think toLowerCase() gives every time a new obj? am i right?
let me know?
Raghusham Sankargal
Originally posted by venkataramana ramana:
...I think toLowerCase() gives every time a new obj? am i right?
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
"I'm not back." - Bill Harding, Twister
Originally posted by pravin kumar:
...so after using 'intern()' method..does it make 't' and 'u' to refer to the same object as "t==u" returns true Please guide on it
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Jim Yingst:
... It turns out that if a String is already all lowercase, then the method just returns the original string, without creating a new one. This fact is not documented, but it can be seen in source code or verified experimentally...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Consider Paul's rocket mass heater. |