在java中,数组不能放不同数据类型的值. 方法一: 多态 定义数组类型的时候定义为父类,而存进数组为父类的子类 public class test2 { public static void main(String args[]) { father []a = new father[2]; a[0] = new son(); a[1] = new son2(); } } class father{ int i = 0; } class son extends father{ int x = 0…