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. thanks i am fresher to j2me i understand the conce
View Tutorial          By: anusha at 2010-04-20 00:32:10

2. When the Value Is Returned To The Method Then How
View Tutorial          By: nitin deep singh at 2011-08-09 11:43:07

3. Hi guys.i have a simple doubt.
i want to ru

View Tutorial          By: Muthukumar at 2011-12-29 07:30:56

4. Thnx Ramlak,but be ware about syntax errors.
View Tutorial          By: Saber at 2008-11-03 07:45:23

5. is anyone going to post the complete version of th
View Tutorial          By: anon at 2009-04-21 12:26:51

6. i want to know how to connect one page to another
View Tutorial          By: mahesh at 2009-08-26 01:31:40

7. @Askia-Just change RadioButton1 to RadioButton2 in
View Tutorial          By: Nelson at 2010-03-06 23:12:36

8. @Prab, no its 7 since it starts the counting at 0
View Tutorial          By: Shadowfaux at 2009-11-21 15:22:49

9. notify does NOT wake up the first thread waiting.
View Tutorial          By: Armin at 2009-07-26 07:25:09

10. it giving me error in following statment (using Li
View Tutorial          By: Priyadarsan at 2007-11-27 22:31:56