import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] v = new int[n];
}
}
这样做有什么问题吗?
最佳答案
没有。 (n
之外的其他值可能为负数,或者很大,导致拒绝服务 (DoS) 情况。)
对于数组,以后无法更改其大小。您必须创建一个新数组,复制内容并切换所有引用。
关于java - java中没有 vector 的动态数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2308044/