Java中的动态定义数组
2021-01-28 07:16
标签:nbsp bsp system integer ann imp for exti int() 1.一维矩阵的动态定义(代码注释) 1.1方法一 1.2方法二(多维数组也可用这种方法) 2.二维数组 3.二维数组与多维数组(1.2方法二) Java中的动态定义数组 标签:nbsp bsp system integer ann imp for exti int() 原文地址:https://www.cnblogs.com/sped-/p/12838803.htmlpackage dongtai;
import java.util.Scanner;
import java.util.ArrayList;
public class DongTai {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ArrayList
package dongtai;
import java.util.Scanner;
public class DongTai {
public static int []p; //直接定义一个一维数组
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
p = new int[num]; //可直接定义数组大小
}
}
package dongtai;
import java.util.Scanner;
public class DongTai {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int [][] m;
m = new int[n][];
for(int i=1; i
package dongtai;
import java.util.Scanner;
public class DongTai {
public static int arr[][][];
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
arr = new int[n][n][n];
}
}
上一篇:3 - Java基础语法
下一篇:高级数据结构--树状数组