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
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
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. sir there is no startapp(),destroyapp() and pause
View Tutorial By: Sathish at 2012-08-20 08:49:33
2. hello friends .. am looking for the java code that
View Tutorial By: ahmed at 2008-09-18 21:48:21
3. hey i found answer for
Error loading win32c
View Tutorial By: Dinesh557 at 2008-09-23 05:14:09
4. Hi,
I alos faced the same problem o
View Tutorial By: prasanna kumar v at 2010-05-15 02:55:59
5. nice tutorial,but if provided with the complete ex
View Tutorial By: Prasant Kumar Sahu at 2013-01-07 13:17:20
6. I went befly through this, it is woderful, usefull
View Tutorial By: Mallikarjuna.N at 2009-11-28 11:41:58
7. This example is very clear. I cleared my concept o
View Tutorial By: sukanta at 2009-10-20 06:08:50
8. CAN I ASK A FORMULA OF FOR MAKING A CALCULATOR USI
View Tutorial By: JUNER at 2011-08-17 03:33:02
9. plz wait for your solution
View Tutorial By: Desai Rajesh at 2010-03-11 22:00:32
10. please help me to do find a push and pop operation
View Tutorial By: sweet mae at 2011-01-14 00:01:33