f



java.lang.String.

Can anyone tell me what is the difference between the two assignmentsString ref = "HAI";String obj = new String("HAI");
0
7/17/2007 6:24:43 AM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

1 Replies
691 Views

Similar Articles

[PageSpeed] 15

On Tue, 17 Jul 2007 06:24:43 -0000, "M.Ponmalar@gmail.com"
<M.Ponmalar@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>Can anyone tell me what is the difference between the two assignments
>String ref = "HAI";
>String obj = new String("HAI");

The second creates a duplicate object, needlessly.  The first just
assigns a reference to an existing interned string literal object
-- 
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
0
Roedy
7/17/2007 7:04:19 AM
Reply: