This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

destory arrayList

 
brian yuen
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I remove all the element in a arrayList ?
static ArrayList addRecord = new ArrayList();
for(int i=0;i <addRecord.size(), i++)
{
//do some operation;
}
//destory the ArrayList here,
what i want is there's no element in the array list here
...any ideas other than addRecord.remove to remove
all the element in the arrayLIst
thanks
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about addRecord.clear();
 
fred rosenberger
lowercase baba
Bartender
Posts: 12180
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the api is a great place to look for this kind of stuff...
e.g.
http://java.sun.com/j2se/1.4.2/docs/api/
(or whatever version your using)
you can lookup things like Arraylist, and see what methods it has. In this case,
clear()
Removes all of the elements from this list.
 
brian yuen
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic