-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathExample.java
More file actions
39 lines (33 loc) · 1.1 KB
/
Example.java
File metadata and controls
39 lines (33 loc) · 1.1 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
33
34
35
36
37
38
39
import java.util.ArrayList;
import java.util.Scanner;
public class Example {
public static void main(String[] args) {
//1
ArrayList<ArrayList> myList = new ArrayList<>();
//2
int arrayListCount, itemCount;
Scanner scanner = new Scanner(System.in);
//3
System.out.println("Enter total number of ArrayList to add : ");
arrayListCount = scanner.nextInt();
//4
System.out.println("Enter total values for each ArrayList : ");
itemCount = scanner.nextInt();
//5
for (int i = 0; i < arrayListCount; i++) {
//6
System.out.println("Enter all values for ArrayList " + (i + 1) + " : ");
ArrayList list = new ArrayList<>();
//7
for (int j = 0; j < itemCount; j++) {
//8
System.out.println("Enter value " + (j + 1) + " : ");
list.add(scanner.next());
}
//9
myList.add(list);
}
//10
System.out.println(myList);
}
}