Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : Miguel JImenez

Comment Added at : 2009-05-10 14:28:46

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
Thanks for the explanation.
It makes sense. However, I tried this:

String s1 = "Hello";
String s2 = "Hello"; // new String(s1);
System.out.println(s1 + " equals " + s2 + " -> " + s1.equals(s2));
System.out.println(s1 + " == " + s2 + " -> " + (s1 == s2));

and I don't understand the result.
Can someone explain why both result in equal. please?

MJ


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. thanks a lot ..
View Tutorial          By: indra at 2009-03-25 15:40:03

2. I have a source code of j2ee. but i want to conver
View Tutorial          By: bangaram at 2011-06-07 09:28:45

3. thank you man.
View Tutorial          By: Hariharan at 2012-08-03 01:39:16

4. hi MR. A.Balaji
can u help me how you have

View Tutorial          By: mjnanthini at 2010-10-03 23:04:35

5. Please provide web.xml file for this example
View Tutorial          By: Girish at 2009-03-08 22:53:03

6. what items do i add?
View Tutorial          By: Camo at 2015-09-30 23:02:10

7. programs are making the concept easy.its a nice pr
View Tutorial          By: veeru at 2010-05-12 22:10:25

8. send me the code with complete set of java package
View Tutorial          By: meena at 2011-06-15 03:12:17

9. how to run this code....... Please tell somebody m
View Tutorial          By: Honey at 2015-01-24 14:27:38

10. Hi there is two ways you can get information.

View Tutorial          By: Sathyam at 2008-12-15 02:01:22