This commit is contained in:
La Programmatrice Verde
2026-03-24 08:48:06 +01:00
parent f35818db88
commit 1e4c8f2a5f
2 changed files with 28 additions and 2 deletions

View File

@@ -13,6 +13,16 @@ public class Lista<E> {
return this.size;
}
public void addFirst(E info) {
if (this.testa == null) {
this.testa = new Nodo<>(info);
}
else {
Nodo<E> nuovaTesta = new Nodo<>(info);
nuovaTesta.setNext(this.testa);
this.testa = nuovaTesta;
}
}
//addFirst(tipoInfo info): aggiunge un nodo in testa (es. tipoInfo = char, tipoInfo = int)
//addLast(tipoInfo info): aggiunge un nodo in coda (es. tipoInfo = char, tipoInfo = int)