aspose file tools*
The moose likes Java in General and the fly likes Storing and accessing elements from a LinkedList and ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Storing and accessing elements from a LinkedList and ArrayList" Watch "Storing and accessing elements from a LinkedList and ArrayList" New topic
Author

Storing and accessing elements from a LinkedList and ArrayList

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi , i read that a LinkedlIST stores the elements in a FIFO order so its best
suited when we want to implement a Queue




When i accssed the elements uisng a Iterator the output is

sss1
sss2
sss3
sss4

and also the output is same when i used the



sss1
sss2
sss3
sss4


so please tell me whre is the diffrence?

Save India From Corruption - Anna Hazare.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19759
    
  20

See this thread.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4461
    
    8

A LinkedList implements the Queue interface as well as the List interface (ArrayList doesn't), but to get it to behave like a queue you've got to use the methods in that interface. You're just using the List interface - adding values and then iterating through them in order. All classes implementing List ought to behave the same way doing that.

Try this:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing and accessing elements from a LinkedList and ArrayList