Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class IterativeLinkedList<T> {
  2.  
  3.     private T value;
  4.    
  5.     private IterativeLinkedList<T> next;
  6.  
  7.     public IterativeLinkedList<T> getNext() {
  8.         return next;
  9.     }
  10.  
  11.     public IterativeLinkedList(T value, IterativeLinkedList<T> next) {
  12.         super();
  13.         this.value = value;
  14.         this.next = next;
  15.     }
  16.  
  17.     public IterativeLinkedList(T value) {
  18.         super();
  19.         this.value = value;
  20.     }
  21.  
  22.     public void setNext(IterativeLinkedList<T> next) {
  23.         this.next = next;
  24.     }
  25.  
  26.     public T getValue() {
  27.         return value;
  28.     }
  29.  
  30.     public void setValue(T value) {
  31.         this.value = value;
  32.     }
  33.  
  34.     public T first() {
  35.         return this.getValue();
  36.     }
  37.  
  38.     public T second() {
  39.         if(this.getNext() != null)
  40.         {
  41.             return this.getNext().getValue();
  42.         }
  43.         else
  44.         {
  45.             return null;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement