Collection of bad coding practices

LinkedLists as arrays

leave a comment »

java.util.LinkedList is a special type of collection designed for sequential access (stacks and queues). Being used as a random-accesed array, it is much slower than other List implementations. For instance, getting an item by index (get(n)) has constant complexity O(1) for ArrayLists, while for LinkedList, the complexity of that operation is O(n).

Use ArrayList (or Vector if synchronization is required) for random-accessed lists.


Written by Alex

November 22, 2007 at 1:03 pm

Posted in Collections

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: