aspose file tools*
The moose likes Beginning Java and the fly likes LinkedList and ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "LinkedList and ArrayList" Watch "LinkedList and ArrayList" New topic
Author

LinkedList and ArrayList

Devi Hari
Greenhorn

Joined: Oct 03, 2005
Posts: 7
what is the difference between LinkedList and ArrayList
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

They are different implementations of the List interface.

LinkedList works with a linked list behind the scenes. ArrayList works differently, it has an array behind the scenes.

For some operations, ArrayList is more efficient (such as lookups by index), and for other operations, LinkedList is more efficient (such as inserting or deleting entries).

Read the API documentation of ArrayList and LinkedList for more information.

If you have trouble choosing between the two, analyze your application and find out what kind of operations you're doing on your list. Choose the implementation that does the most frequently used operations the most efficiently.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Devi --

First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. A single name isn't enough. You can change your display name here. Thanks!

Second, this is a beginner question, not an advanced one; I'm moving this thread to Java in General (Beginner) for any follow-up.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LinkedList and ArrayList