import java.util.Arrays遍历一维数组
Arrays.toString()
import java.util.Arrays; public class Hello { public static void main(String []args) { int a[]={1,2,3}; System.out.println(Arrays.toString(a)); } }遍历多维数组(以二维数组为例)
Arrays.deepToString()
import java.util.Arrays; public class HelloWorld { public static void main(String []args) { int a[][]={{1,2},{3,4}}; System.out.println(Arrays.deepToString(a)); } }输出多维数组的某一行(以输出二维数组的某一行为例)
import java.util.Arrays; public class HelloWorld { public static void main(String []args) { int a[][]={{1,2},{3,4}}; int b[]=a[1]; System.out.println(Arrays.toString(b)); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)