toString
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user