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. realy very nice artical it give good understable
View Tutorial          By: vivek at 2009-06-19 01:27:46

2. #!/bin/bash

echo "Enter number

View Tutorial          By: ashish at 2011-03-25 07:46:09

3. sir how can i access url in one click
View Tutorial          By: mohit at 2010-05-28 23:10:23

4. Of course you can use this in a web application. A
View Tutorial          By: Ramlak at 2008-09-17 08:24:21

5. I am new in Java and got good information to under
View Tutorial          By: Umesh Kumar at 2012-01-25 08:42:07

6. i want diff example one.....

plz
View Tutorial          By: Santhosh at 2010-07-30 01:35:22

7. Just what I needed. Thank you.
View Tutorial          By: Clive Jefferies at 2009-06-01 08:05:15

8. i have an exception unknown host.
please te

View Tutorial          By: saddam hussain at 2011-03-22 10:46:48

9. u hav done Nice job..
View Tutorial          By: Rakesh at 2012-10-01 16:00:14

10. u can try this out it will satisify u:)
imp

View Tutorial          By: vallabh at 2014-10-04 17:44:18