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. Not bad,but need some implementation
View Tutorial          By: surjeet katwal at 2010-01-19 04:41:15

2. hi,
can you tell me how to run the code to

View Tutorial          By: raghu at 2008-12-26 03:15:52

3. very good explanation... thnx...
View Tutorial          By: gobu at 2009-04-05 23:43:19

4. Very good example! Thanks so much!
View Tutorial          By: Chrissy at 2010-04-14 22:37:56

5. Excellent
View Tutorial          By: Dev at 2008-08-01 02:41:25

6. its really a good post... very informative..
View Tutorial          By: javagava at 2011-12-13 19:49:08

7. my question is how do this program connect to my
View Tutorial          By: ravisskit at 2012-10-08 12:00:18

8. Please note that the above code does not work with
View Tutorial          By: mk at 2012-02-14 15:37:02

9. Thank you... :)
Simple and effective explan

View Tutorial          By: Mohammed Muzammil at 2012-08-08 05:07:32

10. Thanks it worked for me after lot of search for CO
View Tutorial          By: VIRAJ at 2012-12-26 11:56:24