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. how about soting you word? like your output will b
View Tutorial          By: [email protected] at 2011-01-27 16:40:51

2. Hi,

I tried this script with noki

View Tutorial          By: sravan at 2009-07-11 11:17:45

3. Really appreciate, after a long time, I am able to
View Tutorial          By: Senthil at 2012-09-16 06:03:15

4. nice article, many thanx :)
View Tutorial          By: Unknown at 2008-10-16 21:09:02

5. can anybody tell me the full code for sending sms
View Tutorial          By: shikha at 2008-10-13 11:43:40

6. The name OAK was changed to java because ,once the
View Tutorial          By: Sowminarayanan at 2010-11-28 06:17:42

7. How to print lee alone for the eg above........I n
View Tutorial          By: sa at 2013-04-01 07:43:03

8. can i apply multidimensional array list the progra
View Tutorial          By: [email protected] at 2009-07-01 05:09:27

9. at
OK
at+cmff=1
OK
at+

View Tutorial          By: shrinivas at 2009-03-07 23:16:51

10. hi sir
im a student of aitm im doing speec

View Tutorial          By: sinan ahmed at 2015-02-09 05:45:49