File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes destory arrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "destory arrayList" Watch "destory arrayList" New topic
Author

destory arrayList

brian yuen
Greenhorn

Joined: Oct 20, 2003
Posts: 20
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

Joined: May 05, 2000
Posts: 13974
How about addRecord.clear();


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11170
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
brian yuen
Greenhorn

Joined: Oct 20, 2003
Posts: 20
Thanks very much..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: destory arrayList
 
Similar Threads
Enhanced for loop
Remove an element from array by index
Error java util NoSuchElementException
Remove last element of string
arrayList.remove()