-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLessonTwelve.java
More file actions
62 lines (48 loc) · 1.35 KB
/
LessonTwelve.java
File metadata and controls
62 lines (48 loc) · 1.35 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
package newLessons.lessonTwelve;
import java.util.Random;
import newLessons.Lesson;
public class LessonTwelve extends Lesson {
@Override
public void theLesson() {
MyArrayList<String> sList = new MyArrayList<>();
MyArrayList<Integer> iList = new MyArrayList<>(2);
sList.add("A");
sList.add("B");
sList.add("C");
sList.add("D");
sList.add("E");
sList.add("F");
sList.add("G");
sList.add("H");
sList.add("H");
sList.add("I");
sList.add("J");
sList.add("J");
sList.add("J");
Random r = new Random();
for (int x = 0; x < r.nextInt(45); x++) {
iList.add(r.nextInt());
}
for (int x = 0; x < sList.getSize(); x++) {
System.out.println(sList.get(x));
}
for (int x = 0; x < iList.getSize(); x++) {
System.out.println(iList.get(x));
}
// When the things stored in the lists get printed you will see a few null values in there.
// This is because of the fact that we expand by doubling (with an initial size of 10 [2 for the Integer list]) so there are some empty spaces.
}
@Override
public void theAssignment() {
MyLinkedList<String> list = new MyLinkedList<>();
// Remember that our list is 0 indexed.
list.add("First");
list.add("Second");
list.add("Third");
list.add("Fourth`");
System.out.println(list.getSize());
for (int x = 0; x < list.getSize(); x++) {
System.out.println(list.get(x));
}
}
}