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 == .


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. HI can you send send sms throgh java program above
View Tutorial          By: sasikumar at 2007-02-27 01:39:11

2. Thanks,It's perfect solution,I solved my probleam
View Tutorial          By: Suryaprakash Raghuwanshi at 2009-07-04 19:06:24

3. Awesome article. It's very useful. Despite it didn
View Tutorial          By: Matheus at 2015-02-24 12:06:05

4. so what about, if i need to remove these letters f
View Tutorial          By: need Help at 2009-11-12 08:40:31

5. Its so very helpful
View Tutorial          By: Anurag at 2011-02-08 04:27:03

6. can u plz send me jsf material in my gmail.
View Tutorial          By: rajesh at 2013-06-09 11:40:11

7. At my phone number, it showing

5 re

View Tutorial          By: Zafar Iqbal at 2013-04-02 19:48:32

8. Hi Steven. It looks like your example program does
View Tutorial          By: Ben Hallinan at 2008-04-25 08:36:42

9. Sir!
I want the source code for receiv

View Tutorial          By: Anupam Shukla at 2010-04-30 00:09:25

10. Hi to All,
I am working on struts based apl

View Tutorial          By: Ishmayel at 2009-02-19 21:27:14