-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists.java
More file actions
executable file
·94 lines (85 loc) · 2.19 KB
/
Lists.java
File metadata and controls
executable file
·94 lines (85 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package basic.collection.testSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
public class Lists {
private static boolean b;
private static String s;
private static int i;
private static Iterator<String> it;
private static ListIterator<String> lit;
public static void basicTest(List<String> a) {
a.add(1, "x");
a.add("x");
b = a.contains("1");
s = a.get(1);
i = a.indexOf("1");
b = a.isEmpty();
it = a.iterator();
lit = a.listIterator();
lit = a.listIterator(2);
i = a.lastIndexOf("1");
a.remove(1);
a.remove("3");
a.set(1, "y");
i = a.size();
a.clear();
}
public static void iterMotion(List<String> a) {
ListIterator<String> it = a.listIterator();
b = it.hasNext();
b = it.hasPrevious();
s = it.next();
i = it.nextIndex();
s = it.previous();
i = it.previousIndex();
}
public static void iterMainpulation(List<String> a) {
ListIterator<String> it = a.listIterator();
it.add("47");
it.next();
it.remove();
it.next();
it.set("47");
}
public static void testVisuabl(List<String> a) {
System.out.println(a);
a.add("123");
a.add("1233");
a.add("fwe");
a.add("fe");
System.out.println(a);
ListIterator<String> x = a.listIterator(a.size());
x.add("one");
System.out.println(a);
System.out.println(x.next());
x.remove();
System.out.println(x.next());
x.set("47");
System.out.println(a);
x = a.listIterator(a.size());
while (x.hasPrevious()) {
System.out.println(x.previous() + " ");
}
System.out.println();
System.out.println("testVisual finished");
}
public static void testLinkedList() {
LinkedList<String> l = new LinkedList<String>();
l.add("123");
l.add("freew");
l.add("cscs");
l.addFirst("213");
l.addFirst("fw");
System.out.println(l);
System.out.println(l.getFirst());
System.out.println(l.removeFirst());
System.out.println(l.removeFirst());
System.out.println(l.removeLast());
System.out.println(l);
}
public static void main(String[] args) {
// basicTest(new LinkedList<String>())
}
}