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. hay is there any way to perform operation or calcu
View Tutorial          By: neha at 2009-11-20 08:29:45

2. It's good working very well...............
View Tutorial          By: avinash at 2013-03-07 09:38:21

3. it's very good to understand...and it is helpful f
View Tutorial          By: Rakesh at 2009-12-26 00:14:59

4. u said that const function cant change object.can
View Tutorial          By: z at 2010-05-09 12:02:17

5. Hi, Can anyone please tell me where we need to cha
View Tutorial          By: Gunjan at 2014-01-02 12:08:41

6. realy it was a nice basic example...and better def
View Tutorial          By: amit kumar at 2011-03-14 08:11:31

7. it is very good service.
View Tutorial          By: rajesh at 2009-11-14 02:48:18

8. Thank you! Nice article.
View Tutorial          By: Koja at 2013-04-23 20:58:05

9. hi ..

for second code which impleme

View Tutorial          By: Eng at 2009-02-21 03:53:29

10. very good....
View Tutorial          By: satish at 2010-03-03 22:47:25