Java linked list visualizer

A linked list is a chain of objects, each holding a reference to the next. Step through it and the visualizer draws every node as an object, with arrows for the references between them.

Source

line 1
Line that just executed Next line to execute
Sign in to share

Call stack

1
main()
line 1
Step 1/1

What to watch

  • Each new Node becomes its own object, and next starts out as null.
  • head.next.next follows two references to reach the third node.
  • In the loop, current moves along the chain one reference at a time until it reaches null.

Try changing it

  • Insert a new node between the first and second nodes.
  • Write a method that returns the length of the list.

Edit the code above and press Visualize to see your version run.

More Java examples

Or open the Java visualizer and paste your own code.