Lista senza interferenze
This commit is contained in:
parent
215233df98
commit
7be287ed7f
@ -21,7 +21,7 @@ public class ListNI extends SimpleList{
|
||||
else if(!isEmpty()){
|
||||
Object headElem=head();
|
||||
remHead();
|
||||
remAt(pos-1, elem);
|
||||
remAt(pos-1);
|
||||
addHead(headElem);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ import java.util.Scanner;
|
||||
public class Test{
|
||||
public static void main(String [] args) throws Exception {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
SimpleList list = new SimpleList();
|
||||
ListNI list = new ListNI();
|
||||
ListNI list2;
|
||||
|
||||
System.out.println("Stringa: ");
|
||||
String line = sc.nextLine();
|
||||
@ -14,12 +15,20 @@ public class Test{
|
||||
line = sc.nextLine();
|
||||
}
|
||||
|
||||
System.out.println("lunghezza lista: " + list.size());
|
||||
list2=list.copy();
|
||||
list2.addAt(3, "prova");
|
||||
list.remAt(2);
|
||||
|
||||
while(!list.isEmpty()){
|
||||
line = (String) list.head();
|
||||
System.out.println(line);
|
||||
System.out.print(line+" --> ");
|
||||
list.remHead();
|
||||
}
|
||||
System.out.println();
|
||||
while(!list2.isEmpty()){
|
||||
line = (String) list2.head();
|
||||
System.out.print(line+" --> ");
|
||||
list2.remHead();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user