Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1.  
  2. public class Node<T> {
  3.     private T value;
  4.     private Node<T> next;
  5.    
  6.     public Node(T x) {
  7.         this.value = x;
  8.     }
  9.    
  10.     public Node(T x, Node<T> next) {
  11.         this.value = x;
  12.         this.next = next;
  13.     }
  14.    
  15.     public T getValue() {
  16.         return this.value;
  17.     }
  18.    
  19.     public Node<T> getNext(){
  20.         return this.next;
  21.     }
  22.    
  23.     public boolean hasNext() {
  24.         return this.next != null;
  25.     }
  26.    
  27.     public void setValue(T x) {
  28.         this.value = x;
  29.     }
  30.    
  31.     public void setNext(Node<T> next) {
  32.         this.next = next;
  33.     }
  34.    
  35.     @Override
  36.     public String toString() {
  37.         return "Node with value: "+value.toString();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement