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. The same article is originally given on struts apa
View Tutorial          By: Fact at 2011-05-09 16:19:18

2. Excellent tutorial thank you very much.

View Tutorial          By: Edd at 2012-01-15 10:49:00

3. Very precisely and simply explained.
View Tutorial          By: Deepak at 2015-01-05 08:37:01

4. it is working....great
View Tutorial          By: mahesh maduranga at 2011-03-27 23:01:57

5. Thanks a lot this thing was very importent for me!
View Tutorial          By: Andrew at 2010-05-23 01:47:04

6. Good one!!!!!!!!
View Tutorial          By: Manya at 2011-06-30 11:59:25

7. Really great way of explanation..... :)
Tha

View Tutorial          By: akram at 2010-07-08 04:07:17

8. Thanks a ton! :)
View Tutorial          By: Prateek at 2015-03-12 11:40:08

9. Your output is not correct.. Give the correct out
View Tutorial          By: Surendrakumar at 2014-06-04 07:00:16

10. Hi, i am trying this code but at compile time it w
View Tutorial          By: swapnil at 2012-12-16 01:37:57