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. Very good
View Tutorial          By: dizh at 2014-02-21 07:48:19

2. its very nice
View Tutorial          By: keerthi at 2012-06-28 17:04:36

3. I have a problem with PortInUseException. I wrote
View Tutorial          By: robert at 2009-12-28 08:37:49

4. good
View Tutorial          By: osman at 2011-11-21 22:23:02

5. @Palla Subramanyam : Your logic is correct, but SO
View Tutorial          By: Roopesh H at 2012-07-27 04:47:48

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

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

7. this is simple and informative.thanks
View Tutorial          By: amrita at 2011-11-12 14:32:58

8. What is the difference between an Interface and an
View Tutorial          By: RAJA at 2015-06-26 17:28:31

9. can u give me the example simulation of strcat??
View Tutorial          By: farah at 2009-10-05 01:10:02

10. hi ... i want to receive SMS on the com port ... b
View Tutorial          By: Ahsan at 2010-02-16 19:49:26