Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package list;
- /**
- *
- * @author Dmitry Kankalovich, 2011
- */
- public class List<T> {
- private Node head;
- private Node tail;
- private class Node {
- public T obj;
- public Node next;
- public Node(T obj) {
- this.obj = obj;
- }
- }
- public void add(T obj) {
- if(head == null) {
- head = new Node(obj);
- tail = head;
- } else {
- Node current = head;
- while(current.next != null) {
- current = current.next;
- }
- current.next = new Node(obj);
- tail = current.next;
- }
- }
- }
Add Comment
Please, Sign In to add comment