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



Related Tutorials

Java program to get location meta data from an image

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

Archived Comments

1. How we print this structure in C++, with nested lo
View Tutorial          By: Hussnain at 2012-01-27 09:19:41

2. Post your errors, so that others may help you my f
View Tutorial          By: yogesh at 2010-01-12 00:45:42

3. I did this exactly.
In my case, the fix.php

View Tutorial          By: Manorasa at 2010-06-29 23:32:24

4. Thanks a lot lot lot for this, but when I run the
View Tutorial          By: Kedjimo at 2011-10-06 06:13:10

5. an excellentttttttt siteee
View Tutorial          By: raza at 2011-04-02 10:39:46

6. what about (!isset)?? the isset with "!"
View Tutorial          By: bali web design at 2011-04-21 12:51:38

7. not satisfied...

want to print the

View Tutorial          By: nikhil jha at 2010-03-08 04:25:50

8. Very good. I like this way. First provide quite wr
View Tutorial          By: NJ at 2010-04-01 23:27:44

9. Good one.. great for beginners..
View Tutorial          By: varun at 2009-09-29 14:18:04

10. Very good !!
View Tutorial          By: SGK at 2009-04-26 23:53:44