Tuesday, November 25, 2014

Linked List - Java Implementation

Node Definition
      public class Node {  
           private Type data;  
           private Node next;  
           public Node(Type data, Node next) {  
                this.data = data;  
                this.next = next;  
           }  
      }  
Class Definition
 public class LinkedList<Type> implements Iterable<Type> {  
      private Node head;  
      public class Node {  
           private Type data;  
           private Node next;  
           public Node(Type data, Node next) {  
                this.data = data;  
                this.next = next;  
           }  
      }  
      public LinkedList() {  
           head = null;  
      }
}  

No comments:

Post a Comment