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 sir
how can i get started if i want to

View Tutorial          By: simiyu at 2014-03-15 09:13:04

2. class loop8
{
public static voi

View Tutorial          By: ankush singh at 2011-11-04 16:26:36

3. I was using commons-logging-1.0.4.jar previously,
View Tutorial          By: Pradeep at 2009-09-29 06:39:21

4. Hi Fred, I found this link which has more explanat
View Tutorial          By: Boulvat at 2012-09-25 08:36:48

5. its realy gud which clears minor douts regarding t
View Tutorial          By: Shripad at 2010-01-19 05:40:41

6. tnx.
i have problem why is that to slow???

View Tutorial          By: rozhin at 2015-08-21 07:54:42

7. too good post....very easy to understand
View Tutorial          By: Rahul at 2013-03-04 17:09:58

8. Java s ssssss
View Tutorial          By: zoya at 2012-04-27 12:24:59

9. Thanks for the tutorial. I didn't get a lot of tra
View Tutorial          By: jordan at 2012-05-16 13:03:45

10. i want jsp code
View Tutorial          By: KIRTHANA at 2015-07-31 05:29:04