forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListOfLists.java
More file actions
42 lines (30 loc) · 809 Bytes
/
ListOfLists.java
File metadata and controls
42 lines (30 loc) · 809 Bytes
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
package com.zetcode;
import java.util.ArrayList;
import java.util.List;
public class ListOfLists {
public static void main(String[] args) {
List<Integer> l1 = new ArrayList<>();
l1.add(1);
l1.add(2);
l1.add(3);
List<Integer> l2 = new ArrayList<>();
l2.add(4);
l2.add(5);
l2.add(6);
List<Integer> l3 = new ArrayList<>();
l3.add(7);
l3.add(8);
l3.add(9);
List<List<Integer>> nums = new ArrayList<>();
nums.add(l1);
nums.add(l2);
nums.add(l3);
System.out.println(nums);
for (List<Integer> list : nums) {
for (Integer n : list) {
System.out.printf("%d ", n);
}
System.out.println();
}
}
}