Java定义数组的方式有以下几种:
int[] array1 = new int[5];
String[] array2 = new String[10];
double[] array3 = new double[3];
int[] array1 = {1, 2, 3, 4, 5};
String[] array2 = {"apple", "banana", "orange"};
double[] array3 = {1.2, 3.4, 5.6};
int[] array1 = Arrays.copyOf(array2, 5);
String[] array2 = Arrays.copyOfRange(array1, 0, 3);
int[] array1 = new int[]{1, 2, 3, 4, 5};
String[] array2 = new String[]{"apple", "banana", "orange"};
double[] array3 = new double[]{1.2, 3.4, 5.6};
int[][] array1 = new int[3][4];
String[][] array2 = new String[2][];
array2[0] = new String[3];
array2[1] = new String[2];
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: 怎么在idea中新建一个java类