-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask 2.java
More file actions
49 lines (30 loc) · 869 Bytes
/
Copy pathTask 2.java
File metadata and controls
49 lines (30 loc) · 869 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
43
44
45
46
47
48
49
import java.util.Scanner;
import java.util.Random;
import java.util.ArrayList;
class Myclass{
static int pick;
public static void main(String[] args){
int n;
System.out.println("enter array size n");
Scanner s1 = new Scanner (System.in);
n = s1.nextInt();
ArrayList<Integer> list1 = new ArrayList<>(n);
ArrayList<Integer> list2 = new ArrayList<>(n);
Random rand = new Random();
for (int j = 0; j<n; j++)
{
pick = rand.nextInt(2);
list1.add(pick);
}
System.out.println("Contents of list1: " + list1);
for(int j=0;j<n;j++)
{
for (int i = 0; i<n; i++)
{
pick = rand.nextInt(2);
list2.add(pick);
}
System.out.printf("Contents of list2: " ,list2);
}
}
}