permaculture playing cards
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "LinkedList and ArrayList" Watch "LinkedList and ArrayList" New topic

LinkedList and ArrayList

Devi Hari

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: 15042

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

Joined: Jul 08, 2003
Posts: 24195

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]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: LinkedList and ArrayList
It's not a secret anymore!