Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : sraban

Comment Added at : 2011-10-13 12:13:38

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
Hi,it's really nice to see all the comments of the given topic equals() method and '==' .i would like to share the solution of question asked by Vijay.lets see

result for s1==s2 and s1.equals(s2) for following cases?
1)String s1="hello";
String s2="hello";

->Both equals() and "==" give TRUE

2)String s1 = new String("Hello");
String s2 = new String("Hello");

equals() will give TRUE but "==" will give FALSE

3)String s1="hello";
string s2=s1;

In this case also both will give TRUE bez both pointing to same location

Hope this will help u


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 geek, it really helped me. cheers
View Tutorial          By: Geoffrey at 2015-06-08 09:00:40

2. Thanks...it was very helpful :)
View Tutorial          By: Swathi at 2012-01-25 06:49:46

3. I like your explanition its very uesfull
View Tutorial          By: Salah Mohamed at 2011-12-10 15:47:27

4. awesome...its very understandable one..thnq..:)
View Tutorial          By: sharan at 2010-02-08 10:58:17

5. hi iam new to java i need simple java programs pls
View Tutorial          By: naga at 2010-10-06 03:45:18

6. It is really very gud. And wht i suggest u is if
View Tutorial          By: Ragava rao at 2008-07-19 05:33:18

7. Good Luck.........

by Nagarajan(

View Tutorial          By: nagarajan at 2011-06-21 12:14:39

8. how to append data to existing excel sheets withou
View Tutorial          By: nim at 2011-03-23 00:28:10

9. Thanks a lot for this great post.
View Tutorial          By: Ram Para at 2012-03-23 17:07:09

10. if time out at step 6*** Exception is occure

View Tutorial          By: Bharat at 2011-08-17 10:42:23