• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LinkedList and ArrayList

 
Devi Hari
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between LinkedList and ArrayList
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic