Comment on Tutorial - equals( ) Versus == in Java By Mashoud
Comment Added by : saurabh
Comment Added at : 2009-07-30 15:19:49
Comment on Tutorial : equals( ) Versus == in Java By Mashoud
There is no need to fight. ...whatever ku is saying is correct and what arpita experienced is also correct.
Ku will be correct if I say
String s1 = "Hello";
String s2 = "Hello";
the big difference is here I am not explicitly creating a new object , instead if I had used String s2 = new String ("Hello") just like in thread 1 then I will get s1 == s2 not true which arpita got. Arpita if you try s2 = "Hello" in your program you may get true (depends on your jvm)
One more thing what ku said is JVM specific, a particular JVM can choose to maintain String pool while other may not.
String API just guarantees that equals() will work as intended but not == .
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews
Subscribe to Tutorials
1. Thank you for the code. Could you please send me c
View Tutorial By: Ying at 2009-08-17 13:58:16
10. sir i need some simple example of jdbc i cannot un
View Tutorial By: Velkumar.s at 2013-05-15 07:08:37