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



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. Runtime rt=Runtime.getRuntime();
String cmd

View Tutorial          By: saranya at 2014-10-30 05:36:36

2. Doesn't the getline() on line 14 read "once u
View Tutorial          By: poo at 2011-02-22 00:32:44

3. I have one doubt regarding this code,
if th

View Tutorial          By: Yellappa at 2010-06-11 05:49:15

4. Hi Binod,

Since JSP code is execute

View Tutorial          By: Aathi at 2009-05-28 21:20:10

5. Hi, Thanks a lot for this wonderful written steps.
View Tutorial          By: Amar at 2012-09-09 17:19:58

6. It is really very good good notes of Public versus
View Tutorial          By: Nitin Gavande at 2011-07-16 08:47:56

7. Good tutorial sir
View Tutorial          By: vinay at 2012-01-28 12:38:30

8. Hello guys, I'm developing java program to send SM
View Tutorial          By: Rania at 2010-09-08 09:04:47

9. Superb article
View Tutorial          By: Raj at 2015-01-29 11:18:22

10. Plz can u give me some more examples of recursion.
View Tutorial          By: Asadullah at 2010-01-23 06:38:58