Comment on Tutorial - equals( ) Versus == in Java By Mashoud
Comment Added by : saurabh
Comment Added at : 2009-07-30 15:19:49
Comment on Tutorial : equals( ) Versus == in Java By Mashoud
There is no need to fight. ...whatever ku is saying is correct and what arpita experienced is also correct.
Ku will be correct if I say
String s1 = "Hello";
String s2 = "Hello";
the big difference is here I am not explicitly creating a new object , instead if I had used String s2 = new String ("Hello") just like in thread 1 then I will get s1 == s2 not true which arpita got. Arpita if you try s2 = "Hello" in your program you may get true (depends on your jvm)
One more thing what ku said is JVM specific, a particular JVM can choose to maintain String pool while other may not.
String API just guarantees that equals() will work as intended but not == .
View Tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. hi,
i have tried to download the sun api fr
View Tutorial By: raghu at 2009-01-07 05:45:33
2. pls can any one have any idea about storing the ca
View Tutorial By: souhir at 2010-01-30 11:04:48
3. more daitlled coding for me
View Tutorial By: fred at 2008-07-15 05:56:49
4. Plz send code of sending sms from java code...
View Tutorial By: Shekh at 2014-11-27 14:18:25
5. plse can u send me study material or sample questi
View Tutorial By: sneha at 2015-03-12 09:40:49
6. Hi,
I alos faced the same problem o
View Tutorial By: prasanna kumar v at 2010-05-15 02:55:59
7. Hey guys it's working. If not then remove p.waitFo
View Tutorial By: dileep at 2013-01-04 19:51:38
8. Respected sir,
I am trying to embed windows
View Tutorial By: arshad at 2011-10-22 17:05:21
9. I lik the description.
View Tutorial By: Praveen saini at 2012-11-05 10:13:41
10. Please, send me a working JSP version ,i got error
View Tutorial By: Pang at 2008-01-11 00:01:52