提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
知道数组的类别
public class Main { public static void main (String[] args){ int[] iArr = new int[2];/** 来 自 N o w J a v a . c o m**/ int[][] iiArr = new int[2][2]; int[][][] iiiArr = new int[2][2][2]; String[] sArr = {"A", "B"} ; String[][] ssArr = {{"AA"}, {"BB"}} ; String[][][] sssArr = {} ; // A 3D empty array of string // Print the class name for all arrays System.out.println("int[]:" + getClassName(iArr)); System.out.println("int[][]:" + getClassName(iiArr));/**from n o w j a v a . c o m**/ System.out.println("int[][][]:" + getClassName(iiiArr)); System.out.println("String[]:" + getClassName(sArr)); System.out.println("String[][]:" + getClassName(ssArr)); System.out.println("String[][][]:" + getClassName(sssArr)); } // Any java object can be passed to getClassName() method. // Since every array is an object, we can also pass an array to this method. public