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
|
@Override
|
||||||
// posizione n (es. tipoInfo = char, tipoInfo = int)
|
public String toString(){
|
||||||
// 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