-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
55 lines (42 loc) · 1.56 KB
/
Main.java
File metadata and controls
55 lines (42 loc) · 1.56 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
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> myStringList = new ArrayList<String>();
myStringList.add("hello");
myStringList.add("goodbye");
System.out.println("Size: " + myStringList.size());
ArrayList<Integer> myIntList = new ArrayList<>();
myIntList.add(6);
myIntList.add(5);
int sum = 0;
for (int x : myIntList) {
sum += x;
}
System.out.println(sum);
// Vehicle[] vehicles = new Vehicle[3];
// vehicles[0] = new Truck();
// vehicles[1] = new Boat();
// vehicles[2] = new Plane();
// Fillable[] fillables = new Fillable[4];
// fillables[0] = vehicles[0];
// fillables[1] = vehicles[1];
// fillables[2] = vehicles[2];
// fillables[3] = new BottomlessPit();
// for (int item = 0; item < 10000; item++) {
// for (Fillable fillable : fillables) {
// if (!fillable.isFull()) {
// fillable.addItem();
// if (fillable.isFull()) {
// System.out.println("Filled " + fillable.getClass().getName());
// }
// }
// }
// }
// for (Fillable fillable : fillables) {
// if (!fillable.isFull()) {
// System.out.println("After 10,000 items, " +
// fillable.getClass().getName() + " is still hungry for more!");
// }
// }
}
}