Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : Gunjan

Comment Added at : 2010-09-08 19:24:24

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
Hello Friends ,

s1 == s2 will always give false . Because s1 == s2 gives refers to the different memory location .

Note that , in java every object refers to the different memory locations. So , == will always give you false.
If we declare s1=s2 then it will give true . While s1.equals(s2) compares the character within the String object . So it will give true.


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 all, i have tried above code, but am getting fo
View Tutorial          By: shalini Iyer at 2008-04-22 01:20:32

2. Sir , I am doing B.Tech . I want to know more abou
View Tutorial          By: amita saini at 2011-08-05 13:07:35

3. Thanx!!!!....
It helped me to startup with

View Tutorial          By: RAJITHA REDDY at 2011-03-01 02:47:03

4. After coming to second page again I want to go to
View Tutorial          By: Bhagi at 2012-09-23 06:25:54

5. Thanks man it is very very helpfull for me.

View Tutorial          By: qasim azam at 2011-06-15 18:09:35

6. how to download suport to my phone
send me

View Tutorial          By: dede.mouljadie at 2012-04-28 09:39:21

7. but include<iostream> is main function.
View Tutorial          By: glen at 2009-02-03 22:19:22

8. Thank you! This article helped me to solve this pr
View Tutorial          By: Stan Devyatovsky at 2008-09-12 05:20:20

9. why the code had error in status???
View Tutorial          By: matuz at 2011-11-13 11:35:34

10. For Jaime,

Maybe using JavaScript f

View Tutorial          By: Jair Aviles at 2011-11-22 05:49:05