-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathE9 2D array store.java
45 lines (27 loc) · 985 Bytes
/
E9 2D array store.java
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
import java.text.NumberFormat.Style;
import java.util.Arrays;
import java.util.Scanner;
// Store data in 2D array and retrive it.
public class HelloWorld {
public static void main(String[] args) {
int[][] numberStore = new int[10][10];
// store data into the 2D array.
for (int i = 0; i < numberStore.length; i++) {
for (int j = 0; j < numberStore.length; j++) {
numberStore[i][j] = randomGenerate();
}
}
// retrieve the stored data.
System.out.println("Stored Number are: ");
for (int i = 0; i < numberStore.length; i++) {
for (int j = 0; j < numberStore.length; j++) {
System.out.print(numberStore[i][j] + "\t");
}
System.out.println();
}
}
public static int randomGenerate() {
double random = Math.random()*101;
return (int)random;
}
}