Results 1 to 5 of 5
  1. #1
    ajith_raj is offline Member
    Join Date
    Dec 2008
    Posts
    9
    Rep Power
    0

    Question removing reference

    Java Code:
    ArayList list = new ArrayList();
    Is
    Java Code:
    list.remove(0);
    is equal to
    Java Code:
    list = null;

    i mean will the reference in the ArrayList will be deleted in both case

    Thanks

  2. #2
    wolfcro is offline Member
    Join Date
    Feb 2009
    Location
    Italy
    Posts
    51
    Rep Power
    0

    Default

    they are not equal

    Java Code:
    list.remove(0);
    removes the first element from the list
    the list variable still has the reference to the ArrayList instance

    Java Code:
    list = null;
    sets the list variable to null (removes the reference to the ArrayList instance)

  3. #3
    ajith_raj is offline Member
    Join Date
    Dec 2008
    Posts
    9
    Rep Power
    0

    Default

    Is it good to make the list = null whenever it is in no use for better memory management....

  4. #4
    Join Date
    Oct 2008
    Posts
    73
    Rep Power
    0

    Default

    thats good one .. .. . . .. :o
    Rakesh Mehta

  5. #5
    ajith_raj is offline Member
    Join Date
    Dec 2008
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Object and reference
    By katie in forum New To Java
    Replies: 2
    Last Post: 10-19-2009, 04:45 PM
  2. Replies: 0
    Last Post: 04-15-2008, 09:12 AM
  3. Getting the Object Reference Name
    By Deathmonger in forum New To Java
    Replies: 2
    Last Post: 03-12-2008, 03:51 PM
  4. image removing
    By Triss in forum New To Java
    Replies: 3
    Last Post: 01-20-2008, 09:27 PM
  5. Removing characters
    By kDude in forum New To Java
    Replies: 3
    Last Post: 12-03-2007, 03:38 AM

Posting Permissions

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