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. please show many codes in c++....thankZz
View Tutorial          By: Maybelline Hope Bongolan at 2008-08-20 17:50:51

2. i want daily tutorials
View Tutorial          By: ashish at 2007-12-18 04:26:19

3. I want get data from Mysql into Spinner by using P
View Tutorial          By: Dilsha at 2013-07-06 05:17:58

4. i don't use mysql,but oracle.
how to resolv

View Tutorial          By: Mike Zhu at 2009-06-23 19:20:06

5. Thanks.I was searching the internet for a lot of t
View Tutorial          By: Habi at 2011-12-22 07:43:51

6. // Using the comma.
class Comma {
pu

View Tutorial          By: jatin kapoor at 2011-01-22 03:43:10

7. very nice
View Tutorial          By: subbu at 2011-12-03 13:49:32

8. i am trying to run the above example in eclipse bu
View Tutorial          By: Prathyusha at 2015-03-10 11:01:06

9. YA IT'S VERY USEFUL
View Tutorial          By: JOTHIBASU at 2010-12-20 05:29:38

10. Hi friends i am the beginner ..
please guid

View Tutorial          By: Jigar at 2013-05-20 11:04:03