File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Differences Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Differences" Watch "Differences" New topic


Shiva Priya

Joined: Feb 17, 2005
Posts: 5
What is the difference between ArrayList and LinkedList?
What is the difference between Hashtable and Hashmap?
Arto Pastinen
Ranch Hand

Joined: Dec 13, 2002
Posts: 79

I am not sure about LinkedList, but i think that difference to ArrayList, is that it makes possible to iterate to both directorion.

Hashtable is internally synchronized. HashMap is not.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

An ArrayList is the successor to the Vector (both are, in effect, resizeable arrays).

A linked-list is something different.
Read the JavaDocs for a description.
Better yet, get a book or tutorial on data structures. This one is common to most languages.

The HashMap is the successor to HashTable.

All of the Collections are contained in the java.util package:

The second volume of "Core Java" devotes a whole chapter to them.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Shiva Priya

Joined: Feb 17, 2005
Posts: 5
Thanks for the reply.Well I guess I was not very precise in my question.I want the difference between a single linked list and a ArrayList.I think only a double linked list can be travelled bidirectionally not a single linked list.So I am still not sure about the difference.
One more difference between hashtable and hashmap is that Hashmap accepts null values but Hashtable doesn't.I am not sure whether this null values refers to the key or to the value.
Please reply in this context.

Joined: Jul 26, 2004
Posts: 5

Linkedlist does'nt have any size..i mean, it is dynamic in size...!
Where as ArrayList is not. It do have a size..,if it comes out of its
initial will increase it by half it's current size..and it will
maintain the objects in array..but linkedlist is not like that. It
dynamically adds the objects to the end. And ArrayList is prefarable
when size of the list is known or growth rate of the list known...
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I can never keep this in my head, so I made a Collections Crib Sheet. It says ArrayList is faster for append and get by index. LinkedList is faster for insert and delete. I'm pretty sure I got those words from a Sun newsletter.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Differences
It's not a secret anymore!