Both statements accomplish the same thing - they both create a string
object.  The first statement creates the string by presenting a String
Literal.  When the complier encounters a String Literal in the code, it
creates a String Object with the value presented in the quotes.  See -
http://java.sun.com/docs/books/tutorial/java/data/strings.html. Based on the
foregoing, I don't believe there is a difference in memory usage.  I'll keep
looking into it to see if there is anything I'm missing.

On Wed, Nov 25, 2009 at 07:49, analyn flores <[email protected]> wrote:

> Which saves more memory?
>
> String str = "";
> or
> String str = new String();
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]<javaprogrammingwithpassion%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to