After JDK1.5
==foreach for array
int y[]={1,3,5,};
for(int z:y)System.out.print(z+"\t"); ==>1 3 5
==varying number of args
int y[]={1,3,5}
fun(1,3,5,7);
fun(1);
fun(y);
public static void fun(int ... arg) {
for(int x:arg)System.out.print(x+"\t");
System.out.println();
}
没有评论:
发表评论