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?
- Data Science
- React Native
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews