bharat j

Greenhorn
+ Follow
since Apr 11, 2001
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 bharat j

Bharat j

Originally posted by Ana Inna:
hello,
i came accross the following code:
Byte b1 = new Byte("123");
if (b1.toString() == b1.toString())
System.out.println("true");
else
System.out.println("false");
}
could you tell me why it prints "false"?


This is because the == operator checks whether both strings are in the same memory pool .If u try it with the equals method it will return true i.e if (b1.toString().equals(b1.toString()))

22 years ago