Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Node<T> {
- private T value;
- private Node<T> next;
- public Node(T value) {
- this.value = value;
- this.next = null;
- }
- public Node(T value, Node<T> next) {
- this.value = value;
- this.next = next;
- }
- //return true if there is a next node
- public boolean hasNext() {
- return this.next != null;
- }
- public T getValue() {
- return value;
- }
- public void setValue(T value) {
- this.value = value;
- }
- public Node<T> getNext() {
- return next;
- }
- public void setNext(Node<T> next) {
- this.next = next;
- }
- public String print() {
- return "value=" + value + ", next=" + next + " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement