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

Method main

collections/AddingGroups.java:9–23  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

7
8public class AddingGroups {
9 public static void main(String[] args) {
10 Collection<Integer> collection =
11 new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
12 Integer[] moreInts = { 6, 7, 8, 9, 10 };
13 collection.addAll(Arrays.asList(moreInts));
14 // Runs significantly faster, but you can't
15 // construct a Collection this way:
16 Collections.addAll(collection, 11, 12, 13, 14, 15);
17 Collections.addAll(collection, moreInts);
18 // Produces a list "backed by" an array:
19 List<Integer> list = Arrays.asList(16,17,18,19,20);
20 list.set(1, 99); // OK -- modify an element
21 // list.add(21); // Runtime error; the underlying
22 // array cannot be resized.
23 }
24}

Callers

nothing calls this directly

Calls 2

addAllMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected