MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

arrays/CollectionComparison.java:18–40  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

16
17public class CollectionComparison {
18 public static void main(String[] args) {
19 BerylliumSphere[] spheres =
20 new BerylliumSphere[10];
21 for(int i = 0; i < 5; i++)
22 spheres[i] = new BerylliumSphere();
23 show(spheres);
24 System.out.println(spheres[4]);
25
26 List<BerylliumSphere> sphereList = Suppliers.create(
27 ArrayList::new, BerylliumSphere::new, 5);
28 System.out.println(sphereList);
29 System.out.println(sphereList.get(4));
30
31 int[] integers = { 0, 1, 2, 3, 4, 5 };
32 show(integers);
33 System.out.println(integers[4]);
34
35 List<Integer> intList = new ArrayList<>(
36 Arrays.asList(0, 1, 2, 3, 4, 5));
37 intList.add(97);
38 System.out.println(intList);
39 System.out.println(intList.get(4));
40 }
41}
42/* Output:
43[Sphere 0, Sphere 1, Sphere 2, Sphere 3, Sphere 4,

Callers

nothing calls this directly

Calls 4

createMethod · 0.95
showMethod · 0.65
getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected