addFirst
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user