Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

String assignment difference

Thread view: 
M.Ponmalar@gmail.com - 18 Jul 2007 13:54 GMT
What is the difference between the following two String assignment

String ref = "HAI" and String object = new String("HAI");

Answers would be greatly appreciated!
Chris Dollin - 18 Jul 2007 14:24 GMT
> What is the difference between the following two String assignment
>
> String ref = "HAI" and String object = new String("HAI");

The first one has `ref` refer to the (interned) string literal "HAI";
the second one has `object` refer to a copy of it. As a result, the
two string values are .equals but not ==.

Signature

Chris "called by name, not value" Dollin

Hewlett-Packard Limited     Cain Road, Bracknell,                registered no:
registered office:          Berks RG12 1HN                       690597 England

Lew - 18 Jul 2007 15:26 GMT
>> What is the difference between the following two String assignment
>>
[quoted text clipped - 3 lines]
> the second one has `object` refer to a copy of it. As a result, the
> two string values are .equals but not ==.

To the OP:

Do you remember posting this exact same question before, as subject
"java.lang.String."?

That time you asked, Roedy Green answered:
> On Tue, 17 Jul 2007 06:24:43 -0000, "M.Ponmalar@gmail.com"
> <M.Ponmalar@gmail.com> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 7 lines]
> assigns a reference to an existing interned string literal object
> -- Roedy Green Canadian Mind Products The Java Glossary
<http://mindprod.com> <= excellent site for programmers and others

Please do not repost the same question, but instead follow on the same thread
where you originally asked it.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.