int[] a=new int[4];
Run Code Online (Sandbox Code Playgroud)
我认为当数组创建时..如果我是正确的,那么构造函数将调用(将元素赋值为默认值).其中就是构造函数..
不,没有这样的构造函数.java字节码 newarray中有一个专用的操作码,用于创建数组.
例如,这是该指令的反汇编代码 int[] a = new int[4];
0: iconst_4 // loads the int const 4 onto the stack
1: newarray int // instantiate a new array of int
3: astore_1 // store the reference to the array into local variable 1
Run Code Online (Sandbox Code Playgroud)