-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayListExampleSimple.java
More file actions
40 lines (30 loc) · 935 Bytes
/
Copy pathArrayListExampleSimple.java
File metadata and controls
40 lines (30 loc) · 935 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
import java.util.ArrayList;
import java.util.Scanner;
public class ArrayListExampleSimple {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
ArrayList<ArrayList<Integer>> listA = new ArrayList<>(3);
ArrayList<Integer> listB = new ArrayList<>();
listB.add(2);
listB.add(3);
listB.add(4);
listB.add(5);
ArrayList<Integer> listC = new ArrayList<>();
listC.add(2);
listC.add(9);
;
//initialisation
// for(int i=0; i<3; i++){
// list.add(new ArrayList<>());
// }
// //add elements
// for(int i=0; i<3; i++){
// for(int j=0; j<3; j++){
// list.get(i).add(sc.nextInt());
// }
// }
listA.add(listB);
listA.add(listC);
System.out.println(listA);
}
}