This commit is contained in:
La Programmatrice Verde
2026-03-24 09:41:02 +01:00
parent 34a3602b0d
commit fbffb8dfa9

View File

@@ -130,7 +130,22 @@ public class Lista<E> {
}
}
// tipoInfo getElementAt(int pos): restituisce l'info presente nel nodo in
// posizione n (es. tipoInfo = char, tipoInfo = int)
// String toString()
@Override
public String toString(){
if (this.testa != null) {
StringBuilder sb = new StringBuilder();
Nodo<E> coda = this.testa;
while (coda.getNext() != null) {
sb.append("[ ");
sb.append(coda.getInfo().toString());
sb.append(" ]-->");
coda = coda.getNext();
}
sb.append("NULL");
return sb.toString();
}
else {
return "[ ]-->NULL";
}
}
}