java.lang.String. - Java

This is a discussion on java.lang.String. - Java ; Can anyone tell me what is the difference between the two assignments String ref = "HAI"; String obj = new String("HAI");...

+ Reply to Thread
Results 1 to 2 of 2

java.lang.String.

  1. Default java.lang.String.

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


  2. Default Re: java.lang.String.

    On Tue, 17 Jul 2007 06:24:43 -0000, "M.Ponmalar"
    <M.Ponmalar> 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

+ Reply to Thread

Similar Threads

  1. Re: java.io.File to java.lang.String
    By Application Development in forum Java
    Replies: 4
    Last Post: 07-04-2007, 02:45 PM
  2. Re: java.io.File to java.lang.String
    By Application Development in forum Java
    Replies: 0
    Last Post: 07-03-2007, 10:49 PM
  3. modifying java.lang.String.java
    By Application Development in forum Java
    Replies: 8
    Last Post: 03-26-2007, 08:49 AM
  4. Replies: 0
    Last Post: 10-05-2004, 11:25 AM
  5. Replies: 0
    Last Post: 10-05-2004, 11:24 AM