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. Your page does not show the text in the proper col
View Tutorial          By: Warron at 2013-04-04 17:50:22

2. hi..it's very nice..can you send me the version fo
View Tutorial          By: daniel81 at 2010-02-11 09:19:36

3. Simple and effective example
View Tutorial          By: Anand at 2009-02-05 00:18:10

4. Thank alot
View Tutorial          By: Naganatarajan at 2010-01-07 05:54:17

5. iam getting intrest to watch this site
View Tutorial          By: monika at 2013-02-15 15:48:57

6. Very helpful stuff. Might I just add that you didn
View Tutorial          By: Donovan Aces at 2011-09-12 06:08:20

7. know someone how to compare various objects?

View Tutorial          By: Peter at 2009-10-07 07:32:31

8. Please help I want to map the data say username an
View Tutorial          By: akshat at 2011-07-25 12:49:06

9. a bit extra information on robust
View Tutorial          By: mahesh at 2010-02-02 12:05:37

10. Hi there, a nice tutorial. i wanna ask, what about
View Tutorial          By: Alfa at 2013-03-06 04:04:26