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. In Step 2, I was getting this error: 'The term 'Co
View Tutorial          By: Geneie at 2012-11-22 02:28:13

2. Great!
View Tutorial          By: justauser at 2012-08-31 13:57:58

3. Hi
I have final project whit sms program.
View Tutorial          By: AliPour at 2011-09-11 16:51:19

4. Here is my issue. The sql which comes thru the JTD
View Tutorial          By: Kumar at 2012-02-21 02:42:08

5. Its working ,,, gud stuff.
View Tutorial          By: Atul at 2011-07-21 10:34:44

6. thanks this material is very helpful for me
View Tutorial          By: Anonymous at 2009-05-09 08:04:31

7. Awesome, now I can say I've fully understood volat
View Tutorial          By: Andrew at 2012-01-13 18:19:15

8. The tutorial is very usefull, i am happy now
View Tutorial          By: Haneefa at 2013-03-30 06:31:47

9. WHY You are using such huge code for suspending an
View Tutorial          By: pavan kurariya at 2010-01-14 00:35:55

10. thanks emily, this was fantastic... just saved me
View Tutorial          By: philip at 2010-04-10 20:39:08