Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public String toString() {
- StringBuilder res = new StringBuilder();
- if (isEmpty()) {
- // return "woordenlijst is empty";
- res.append(nameList).append(" is empty");
- } else {
- // String antwoord = "The woordenlijst is: ";
- res.append("The ").append(nameList).append(" is: ");
- // Node<T> loper = firstNode;
- // while (loper != null) {
- // // antwoord += loper.getData();
- // // antwoord += " ";
- // res.append(loper.getData()).append(" ");
- // loper = loper.getNext();
- // }
- // // DE LANGE WEG (ALLEEN NODIG IS ZO DOEN) EXPLICIET ITERATOR
- // Iterator<T> it = iterator();
- // while(it.hasNext()) {
- // res.append(it.next()).append(" ");
- // }
- // //BETER
- // for(T elem : this) { // IMPLECIET ITERATOR
- // res.append(elem).append(" ");
- // }
- //BESTE
- forEach(elem -> res.append(elem).append(" "));
- }
- // return antwoord;
- return res.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement