forked from teddyzhang1976/ThinkInJava4thSampleCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayNew.java
More file actions
18 lines (17 loc) · 490 Bytes
/
ArrayNew.java
File metadata and controls
18 lines (17 loc) · 490 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//: initialization/ArrayNew.java
package initialization; /* Added by Eclipse.py */
// Creating arrays with new.
import java.util.*;
import static net.mindview.util.Print.*;
public class ArrayNew {
public static void main(String[] args) {
int[] a;
Random rand = new Random(47);
a = new int[rand.nextInt(20)];
print("length of a = " + a.length);
print(Arrays.toString(a));
}
} /* Output:
length of a = 18
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
*///:~