Vanguri Jagannadh

Greenhorn
+ Follow
since Apr 05, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vanguri Jagannadh

Thanks for reply.

My doubt is when String s1 = "hi".toUpperCase() gets executed

does it not create both "hi" and "HI" in string pool?

If it gets created I was expecting s == s1 to print true.

Can you please tell me where I went wrong .

--> Jagannadh.V
1. String s1 = "hI".toUpperCase();
2. String s2 = "HI".toUpperCase();
3. String s = "HI";

4. System.out.println(s == s1); // Prints False
5. System.out.println(s == s2); // Prints True

Can some body please explain why line 4 is printing false and
line 5 is printing true.