Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. @Override
  2.     public String toString() {
  3.         StringBuilder res = new StringBuilder();
  4.     if (isEmpty()) {
  5.         // return "woordenlijst is empty";
  6.         res.append(nameList).append(" is empty");
  7.     } else {
  8.         // String antwoord = "The woordenlijst is: ";
  9.         res.append("The ").append(nameList).append(" is: ");
  10.  
  11. //        Node<T> loper = firstNode;
  12. //        while (loper != null) {
  13. //            // antwoord += loper.getData();
  14. //            // antwoord += " ";
  15. //            res.append(loper.getData()).append(" ");
  16. //            loper = loper.getNext();
  17. //        }
  18.  
  19. //        // DE LANGE WEG (ALLEEN NODIG IS ZO DOEN) EXPLICIET ITERATOR
  20. //        Iterator<T> it = iterator();
  21. //        while(it.hasNext()) {
  22. //            res.append(it.next()).append(" ");
  23. //        }
  24.  
  25. //          //BETER
  26. //          for(T elem : this) {        // IMPLECIET ITERATOR
  27. //            res.append(elem).append(" ");
  28. //          }
  29.             //BESTE
  30.             forEach(elem -> res.append(elem).append(" "));
  31.     }
  32.  
  33.     // return antwoord;
  34.     return res.toString();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement