Home > Back-end > Existing code as follows: int [] a=new int [100]. Is a [50] value, please? Why is that?
Existing code as follows: int [] a=new int [100]. Is a [50] value, please? Why is that?
Time:09-19
Is a [50] value, please?
CodePudding user response:
0 bai, you are just the new array has a length of 100, there is no set value, how much is a 0
CodePudding user response:
A [50] is null, you just create a length of 100 int array, there is no assignment
CodePudding user response:
Because it is in the heap, so new JVM automatically to array assignment, Int type definition of an array, initialize the default is 0 Of the definition of type String array, the default value is null Char array type definition, the default value is 0, the corresponding characters Double array type definition, the default value is 0.0 Array of float type definition, the default value is 0.0 Array of Boolean type definition, the default value is false