This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


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

Differences

Shiva Priya
Greenhorn

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
Hi!

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.

Artsi
Ben Souther
Sheriff

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.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html
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:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/package-frame.html

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
Greenhorn

Joined: Feb 17, 2005
Posts: 5
Hi!!
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.
V
Greenhorn

Joined: Jul 26, 2004
Posts: 5
Hi..,

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 size..it 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: http://aspose.com/file-tools
 
subject: Differences
 
Similar Threads
JRE vrs. JVM
Difference between gems and plugins
Plugins and Gems
Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners
Run as AWT or SWT Application Eclipse Question