2015-04-20 15:36:01 -07:00
|
|
|
|
//: initialization/ArrayNew.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// 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]
|
|
|
|
|
*///:~
|