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. why do't you create ActionErrors object like this<
View Tutorial          By: veera reddy at 2011-07-15 12:14:57

2. This example really works and help a lot me to dis
View Tutorial          By: Monu Kumar at 2010-03-30 09:26:23

3. thanks for this tutorial
View Tutorial          By: d3ptzz at 2009-08-03 23:38:57

4. Thanks, you save my day!
View Tutorial          By: ivex at 2015-06-25 20:20:07

5. It encourage the learners

Learners

View Tutorial          By: sureshkumar p at 2010-12-22 04:13:04

6. can u tell me mobile tracker code in j2me
w

View Tutorial          By: aiyaz at 2010-08-21 16:29:08

7. 1
View Tutorial          By: hamza at 2015-06-08 15:09:29

8. Mail me Codings in java of different programs
View Tutorial          By: vikram at 2008-09-12 06:04:42

9. Hello,

When I put the source code i

View Tutorial          By: Pascal at 2013-03-25 09:12:47

10. Good explanation... very helpfull
View Tutorial          By: Ananth at 2009-02-02 00:26:05