File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ArrayList performance for Large Objects. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ArrayList performance for Large Objects." Watch "ArrayList performance for Large Objects." New topic
Author

ArrayList performance for Large Objects.

Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Hi all,

I want to confirm one thing about performance of arraylist.

I have to read a file and get 5000 objects containing two strings each.. and pass it on... I am currently using an ArrayList to pass the objects to the next level.. i wanted to know should i go ahead using ArrayList.?? please advice.. will it be a problem with Heap Space / Memory...

Thanks in advance..

Regards.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

ArrayList is very efficient in terms of storage. It's also very efficient if you need to iterate over the list items in order. It's very inefficient, however, at adding or deleting items from the beginnng or the middle of the list, in which case LinkedList is better (of course, LinkedList uses much more memory per element.)


[Jess in Action][AskingGoodQuestions]
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

thank you so much! i will go ahead then i dont have adding and deleting requirements

i cant believe i got a reply from you Ernest...

Regards.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39380
    
  28
There is a method specific to ArrayList which might make adding 5000 elements even faster: here.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

thanks a lot
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39380
    
  28
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList performance for Large Objects.