public static void main(String[] args) {
int[] ages={1,2,3,4,5};
Listlist = new ArrayList ();
for(int i=0;ilist.add(ages[i]);
}
System.out.println(list.toString());
}
实现二维数组的横竖转换的Java程序如下: public class M { public static void main(String[] args) {int[][] a={{1,2,3},{4,5,6}}; //定义转换矩阵数组 int[][] b=new int[a[0].length][a.length]; //给转换矩阵数组赋值 for(int i=0;i
public static void main(String[] args) {
int[] ages={1,2,3,4,5};
System.out.print("[");
for (int i = 0; i < ages.length-1; i++) {
System.out.print(ages[i]+",");
}
System.out.println(ages[ages.length-1]+"]");
}