1.使用Object[]存储: public class Print { public static void main(String[] args) { Object[] array = returnAObject(); String a = (String) array[0]; Struct b = (Struct) array[1]; int i = (Integer) array[2]; System.out.println(a); System.out.println(b.s); System.out.println(i); } public static Object[] returnAObject() { Object[] array = new Object[4]; //对象数组现在存放不同类型的数据. array[0] = "abc"; array[1] = new Struct(); array[2] = 3; return array; } } class Struct {//随便写一个类 public int a = 3; public String s = "Hello World!"; public Struct() {//安全留空 } } 2.使用类存储: public class Print { public static void main(String[] args) { Struct struct=returnStruct(); System.out.println(struct.nubmer); System.out.println(struct.string); } public static Struct returnStruct() { Struct a=new Struct(); return a; } } class Struct {//随便写一个类,number与string就是不同类型的数据. public int nubmer = 3; public String string = "Hello World!"; public Struct() {//安全留空 } } 3.还有一种是将不同类型数据转换成字节流后,存放到枚举里(不过,我暂时还不会写.)