📄 ex18(3).java
字号:
// arrays/Ex18.java
// TIJ4 Chapter Arrays, Exercise 18, page 775
// Create and fill and array of BerylliumSphere. Copy this array
// to a new array and show that it's a shallow copy.
import java.util.*;
public class Ex18 {
public static void main(String[] args) {
BerylliumSphere[] bsa1 = new BerylliumSphere[3];
for(int i = 0; i < bsa1.length; i++)
bsa1[i] = new BerylliumSphere();
// Arrays.fill(bsa1, new BerylliumSphere());
System.out.println(Arrays.toString(bsa1));
BerylliumSphere[] bsa2 = new BerylliumSphere[4];
System.out.println(Arrays.toString(bsa2));
System.arraycopy(bsa1, 0, bsa2, 0, bsa1.length);
System.out.println(Arrays.toString(bsa2));
// no new BerylliumSpheres created in bsa2,
// just new references to those in bsa1
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -