class Parent { }
class Child extends Parent { }
class Child2 extends Parent { }
public class ArrayTest {
public static void main(String[] args) {
Parent[] arr1 = new Child[3];
arr1[0] = new Parent(); //1
arr1[1] = new Child(); //2
arr1[2] = new Child2(); //3
arr1[3] = new Child(); //4
Child2[] arr2 = {new Child2(), new Child2(), new Child2()};
add(arr2);
}
public static void add(Parent[] arr) {
arr[0] = new Parent(); //5
arr[1] = new Child(); //6
arr[2] = new Child2(); //7
arr[3] = new Child2(); //8
}
}
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати