Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LinkedList<E> {
- // the first element of this LinkedList
- private Node start;
- // the last element of this LinkedList
- private Node end;
- // the number of elements that constitute this LinkedList
- private int length;
- private class Node {
- private Node last;
- private Node next;
- private E data;
- // each Node has a reference to the previous Node and
- // the next Node. The first element of the LinkedList
- // will have a null reference to the previous element
- // and the last element will have a null reference to
- // the next element. Each Node stores a piece of data
- // in the data variable.
- }
- public void clear() {
- start = null;
- end = null;
- length = 0;
- }
- // other methods omitted
- }
- LinkedList
- | |
- Node1 Node2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement