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 wei long, did you download all the five program
View Tutorial          By: Ramlak at 2008-06-23 03:26:31

2. Better theory for those who have just started.

View Tutorial          By: kunal at 2010-05-13 05:55:05

3. @bibiki, you are right for simpler conditions what
View Tutorial          By: Marcin at 2012-04-05 02:34:13

4. Thanks...Really nice...
View Tutorial          By: Raj at 2013-02-07 08:58:28

5. when i trying to build the above program it is giv
View Tutorial          By: bhagyalaxmi at 2008-10-10 23:45:45

6. Easy and Wonderfulimple Example...to undersatnd th
View Tutorial          By: Chaitanya at 2010-04-04 02:27:04

7. Exception in thread "Thread-0" java.lang
View Tutorial          By: yash at 2009-09-16 06:12:32

8. Thank alot
View Tutorial          By: Naganatarajan at 2010-01-07 05:54:17

9. how to run the sms sending program
wether v

View Tutorial          By: ram at 2008-02-26 22:30:13

10. Good Explanation.
View Tutorial          By: Ashishkumar Haldar at 2013-01-03 11:47:25