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. grazie!!!
View Tutorial          By: Egidio De Lorenzo at 2011-04-20 12:07:25

2. Can u tall me about the job market of J2ME.
View Tutorial          By: mimdad07 at 2009-06-26 14:40:26

3. How to sort an Arraylist in some given order? Say,
View Tutorial          By: Arunava Chatterjee at 2015-03-07 04:17:51

4. good
View Tutorial          By: gummalla subbarao at 2011-03-09 01:24:58

5. I want inserted switch statement in my program,
View Tutorial          By: shah at 2011-02-07 01:11:12

6. Thanks. Well explanation..
View Tutorial          By: Ebi Divakar at 2011-07-26 04:31:30

7. very good for programing
View Tutorial          By: kiran at 2007-12-06 00:39:47

8. good for learners
View Tutorial          By: muhammed at 2012-11-20 10:38:28

9. Your site is a really big help. Straight to point
View Tutorial          By: Mark Anthony Santos at 2008-12-16 22:03:57

10. good
View Tutorial          By: Sudip Khatiwara at 2010-04-23 00:52:58