声明后,Java中的数组大小是固定的吗? [英] The array size in Java is fixed after declaration?
本文介绍了声明后,Java中的数组大小是固定的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道声明后Java数组是否已修复。当我们这样做时:
I wanted to know if the Java arrays are fixed after declaration. When we do:
int a [10];
然后我们可以这样做:
a = new int [100];
我不确定第一个语句是否已经分配了一些内存,第二个语句是否分配了一大块内存并重新分配并覆盖了之前的引用。
I am unsure if the first statement already allocates some memory and the second statement allocates a new chunk of memory and reassigns and overwrites the previous reference.
推荐答案
是的:
数组的长度是在数组时建立的被建造。创建
后,其长度是固定的。
The length of an array is established when the array is created. After creation, its length is fixed.
取自这里。
此外,在您的问题中第一个场景: int a [10]
在语法上是不正确的。
Also, in your question the first scenario: int a[10]
is syntactically incorrect.
这篇关于声明后,Java中的数组大小是固定的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文