Results 1 to 2 of 2
  1. #1
    indranil is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Exclamation String Object Creation

    String s1=new String("NEWSTRING");
    String s2=new String("NEWSTRING");

    Will JVM create 2 seperate object in the pool memory??

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,311
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by indranil View Post
    String s1=new String("NEWSTRING");
    String s2=new String("NEWSTRING");

    Will JVM create 2 seperate object in the pool memory??
    There will be three String objects: one pointed to by s1, one pointed to by s2 and one stored in the String pool; all three String objects share the same char array that contains the letters "NEWSTRING".

    kind regards,

    Jos

Similar Threads

  1. Replies: 3
    Last Post: 03-24-2010, 12:24 AM
  2. object creation
    By enygma in forum Java Applets
    Replies: 0
    Last Post: 01-05-2010, 10:01 AM
  3. Object creation and construstion
    By abimaran in forum New To Java
    Replies: 8
    Last Post: 12-15-2009, 09:58 AM
  4. Object creation and memory issues
    By bugger in forum New To Java
    Replies: 11
    Last Post: 11-29-2007, 12:56 PM
  5. String vs Object
    By Gilgamesh in forum New To Java
    Replies: 1
    Last Post: 11-28-2007, 10:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •