This commit is contained in:
La Programmatrice Verde
2026-03-24 08:51:58 +01:00
parent 1e4c8f2a5f
commit f018d72b9c

View File

@@ -24,7 +24,21 @@ public class Lista<E> {
}
}
//addFirst(tipoInfo info): aggiunge un nodo in testa (es. tipoInfo = char, tipoInfo = int)
public void addLast(E info) {
if (this.testa == null) {
addFirst(info);
}
else {
Nodo<E> nuovaCoda = new Nodo<>(info);
Nodo<E> coda = this.testa;
while (coda.getNext() != null) {
coda = coda.getNext();
}
coda.setNext(nuovaCoda);
}
}
//addLast(tipoInfo info): aggiunge un nodo in coda (es. tipoInfo = char, tipoInfo = int)
//addElementAt(tipoInfo info, int pos): aggiunge un nodo nella posizione indicata da pos
//removeFirst(): rimuove il nodo in testa