1 package cn.skyfffire; 2 3 import java.util.ArrayList; 4 5 class A { 6 int i; 7 } 8 9 /** 10 * 11 * @author skyfffire 12 * 13 */ 14 public class Test { 15 static void f(Object[] x) { 16 for (int i = 0; i <= x.length - 1; i++) { 17 System.out.println(x[i]); 18 } 19 } 20 21 public static void main(String[] args) { 22 /* 可以发现, Object作为根类, 是可以容纳所有类型的数组!其初始化方式将在以后说明 */ 23 f(new Object[] {new Integer(33), new ArrayList<Object>(), new Float(2.33), new Double(22.33)}); 24 f(new Object[] {"one", "two", "three"}); 25 f(new Object[] {new A(), new A(), new A()}); 26 } 27 }