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. I need you to Write me a program to initialize one
View Tutorial          By: Sayed maseer at 2015-06-20 05:09:12

2. How can i read PDF files from external memory(SD c
View Tutorial          By: Aswanth at 2014-03-31 09:46:26

3. Hello,
Thank you very much for this sample

View Tutorial          By: Alex at 2010-08-12 07:30:32

4. i want to know how to connect one page to another
View Tutorial          By: mahesh at 2009-08-26 01:31:40

5. thankssss to prograem
View Tutorial          By: maha at 2010-05-21 05:14:36

6. This is very useful for java beginners
View Tutorial          By: Syed Musthafa at 2011-11-20 07:11:50

7. it is good site , and i have cleared my doubts
View Tutorial          By: imtiaz at 2009-10-15 23:43:50

8. hi i unable to retrive am getting below excepti
View Tutorial          By: vignesh at 2015-03-25 17:14:58

9. hi.I am new in j2me and really want to learn more
View Tutorial          By: A.vinothKumar at 2012-08-20 07:50:26

10. i found this very pleasing for both my brain and m
View Tutorial          By: Matthew Redisons at 2012-10-03 14:36:32