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. I really thanks to you for providing wonderful inf
View Tutorial By: Chandra Sekhar Puli at 2009-11-07 04:03:44
2. this is the thread object and thread name
View Tutorial By: narain at 2011-12-06 07:33:07
3. Thanks lot.Its working good...... thanks lot lot..
View Tutorial By: Mohanraj at 2011-12-07 05:23:26
4. Very precise and informative tutorial. Appreciated
View Tutorial By: Rishi Raj at 2011-07-08 12:25:04
5. in my application i have got several command link,
View Tutorial By: Carlo at 2009-09-04 04:48:23
6. I executed your code but i get the error "OK
View Tutorial By: Denzil at 2013-01-18 09:33:37
7. sir, i want to learn java please help me.
View Tutorial By: nitin mittal at 2013-12-23 10:04:11
8. i am using the same code to read data from an RFID
View Tutorial By: JayS at 2015-02-03 21:31:36
9. Nice tutorial, I got how it's done, but the differ
View Tutorial By: FriendlyNoob at 2015-07-20 17:27:08
10. that's what I've been looking for!!!!!!!!!!!!!!!!!
View Tutorial By: bibi at 2014-12-28 20:43:56