This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating Linked List

 
deshdeep divakar
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody tell me how can I implement Linked List without
using util class
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry this is not in the scope of SCJP so it's now here.
[ November 02, 2004: Message edited by: Barry Gaunt ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A singly linked list has a pointer from each element to the next. Let's make a Node class that holds a pointer to the next Node and some object that you put there:

We could build a list like this (just typing, not compiling or testing!)

When I first started making these things, I had to draw each new node on a piece of paper and draw arrows for the "next" pointers. After a while it made sense.

For more fun, think about removing a node in the middle, or the first node. If you really think that was fun, come back and we'll talk about doubly linked lists!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic