-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayOptions.java
More file actions
56 lines (46 loc) · 1.41 KB
/
ArrayOptions.java
File metadata and controls
56 lines (46 loc) · 1.41 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package btp.oneP;
import java.util.Arrays;
public class ArrayOptions {
public static void main(String[] args) {
BerylliumSphere[] a = null;
BerylliumSphere[] b = new BerylliumSphere[5];
System.out.println(a);
System.out.println(b);
System.out.println(Arrays.toString(b));
BerylliumSphere[] c = new BerylliumSphere[4];
for(int i=0;i<c.length;i++){
if(null == c[i]){
c[i] = new BerylliumSphere();
}
}
BerylliumSphere[] d = {
new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere()
};
a = new BerylliumSphere[]{
new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere()
};
System.out.println("a.length:"+a.length);
System.out.println("b.length:"+b.length);
System.out.println("c.length:"+c.length);
System.out.println("d.length:"+d.length);
a = d;
System.out.println("a.length:"+a.length);
int[] e;
int[] f = new int[4];
System.out.println("f:"+Arrays.toString(f));
int[] g = new int[4];
for(int i=0;i<g.length;i++){
g[i] = i*i;
}
int[] h = {11,47,93};
System.out.println("f.length:"+f.length);
System.out.println("g.length:"+g.length);
System.out.println("h.length:"+h.length);
e = h;
System.out.println("e.length:"+e.length);
e = new int[]{1,2};
System.out.println("e.length:"+e.length);
char[] cs = new char[5];
System.out.println(Arrays.toString(cs));
}
}