-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerComparison.java
More file actions
32 lines (30 loc) · 1.06 KB
/
ContainerComparison.java
File metadata and controls
32 lines (30 loc) · 1.06 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
package chap16_Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by Administrator on 2017/4/14.
*/
public class ContainerComparison {
public static void main(String[] args) {
BerylliumSphere[] spheres = new BerylliumSphere[10];
for (int i = 0; i < 5; i++) {
spheres[i] = new BerylliumSphere();
}
System.out.println(Arrays.toString(spheres));
System.out.println(spheres[4]);
List<BerylliumSphere> sphereList = new ArrayList<BerylliumSphere>();
for (int i = 0; i < 5; i++) {
sphereList.add(new BerylliumSphere());
}
System.out.println(sphereList);
System.out.println(sphereList.get(4));
int[] integers = {0, 1, 2, 3, 4, 5};
System.out.println(Arrays.toString(integers));
System.out.println(integers[4]);
List<Integer> intList = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5));
intList.add(97);
System.out.println(intList);
System.out.println(intList.get(4));
}
}