Results 1 to 3 of 3

Thread: new ArrayList

  1. #1
    Join Date
    Jul 2012
    Posts
    33
    Rep Power
    0

    Default new ArrayList

    Hi

    If I create a new arraylist within a method that's called every time the user presses a particular button, will the old arraylist with the same name be automatically replaced after repeated presses of the button?

    Thanks, R

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,044
    Rep Power
    20

    Default Re: new ArrayList

    Java Code:
    public void someMethod() {
       ArrayList al = new ArrayList();
       etc etc
    }
    Each time the above is called, a new ArrayList object is created.
    At the end of that method that object becomes eligible for garbage collection.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Jul 2012
    Posts
    33
    Rep Power
    0

Similar Threads

  1. Replies: 12
    Last Post: 07-07-2011, 08:49 PM
  2. Replies: 1
    Last Post: 05-15-2011, 06:07 PM
  3. copying contents of an ArrayList to another ArrayList
    By ankit1801 in forum New To Java
    Replies: 8
    Last Post: 03-27-2011, 06:07 AM
  4. Replies: 7
    Last Post: 11-22-2010, 01:26 PM
  5. Replies: 2
    Last Post: 04-21-2008, 11:43 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
  •