• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Arraylist or linked list

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is difference between arraylist and linked list?which is faster?
 
Rancher
Posts: 1776
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read through http://download.oracle.com/javase/6/docs/api/java/util/ArrayList.html and http://download.oracle.com/javase/6/docs/api/java/util/LinkedList.html.

Faster? - it depends on the operation you intend to do with them (... and of course the way the code is written!)
 
lowercase baba
Posts: 13062
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

which is faster?


You will quickly learn that the answer to almost EVERY question related to programming and "which is better/faster" is always "It depends". In a nutshell, it is going to be faster to FIND a specific element (I.e the 27th) in an array.

Searching for the element where you don't know the location will be roughly the same for both - unless they are sorted, then an array can be faster.

Inserting a new element in the middle will be faster in a linked list...although I'm not sure if that is still true if you have to find the spot to insert it.

In short, there is no simple answer to the question as stated.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic