增强遍历和Object多参数遍历
public class T2 { public void t1(Object o){//Object是任何类型,多态 System.out.println(o.toString()); } public void t2(int b,Object...args){ for (Object c:args){//遍历args System.out.println(c); } } public static void main(String[] args) { String[] a={"1","2","3","4"}; for (String b:a){ System.out.println(b); } System.out.println("*******"); T2 t2 = new T2(); t2.t1(1); System.out.println("--------------"); t2.t2(0,2,3,4,5); } }