Node.java 800 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. public class Node<E> {
  2. private final E element;
  3. private Node<E> next;
  4. /**
  5. * Constructor.
  6. *
  7. * @param element the element you want to add
  8. */
  9. public Node(E element) {
  10. this.element = element;
  11. }
  12. /**
  13. * Getter for the content of this node.
  14. *
  15. * @return the element
  16. */
  17. public E getElement() {
  18. return element;
  19. }
  20. /**
  21. * @return the next
  22. */
  23. public Node<E> getNext() {
  24. return next;
  25. }
  26. /**
  27. * @param next the next to set
  28. */
  29. public void setNext(Node<E> next) {
  30. this.next = next;
  31. }
  32. /*
  33. * (non-Javadoc)
  34. *
  35. * @see java.lang.Object#toString()
  36. */
  37. @Override
  38. public String toString() {
  39. return "Node[element=" + element + "]";
  40. }
  41. }