Home > Back-end >  Java must be by the use of the local variable display initialization??????
Java must be by the use of the local variable display initialization??????

Time:11-24



Java must be by the use of the local variable display initialization? If so, the variable b is the wrong!!!!!!!!!!

CodePudding user response:

Initialization is your b ah, you have new an array, it has been initialized

CodePudding user response:

Yes, b is an array of objects, the new is initialized, b
As for the initialization of the array elements (I think lz doubts here), Java will give it an initial value, different types of default Boolean is false, int is zero, the object type is null, so new to the array object can directly use the array elements, but the array elements is the default, is likely to go wrong, usually want another assignment (especially the object types, array element is null, so for array element again new),

CodePudding user response:

Method of the variable is, class variables do not need

CodePudding user response:

Java specification, one of the first initialization in use

CodePudding user response:

refer to the second floor qybao response:
yes, b is an array of objects, the new is initialized, b
As for the initialization of the array elements (I think lz doubts here), Java will give it an initial value, different types of default Boolean is false, int is zero, the object type is null, so new to the array object can directly use the array elements, but the array elements is the default, is likely to go wrong, usually want another assignment (especially the object types, array element is null, so for array element again new),

See
Boolean [b] is to statement of array b, Boolean b []=new Boolean [9] is to life and initialize array b
Recently, looking back at the JAVA programming ideas learned
  • Related