The old saying of array initialization in Java
Array initialization can be divided into two types:
1. Static initialization
2. Dynamic initialization
Static initialization:
Example:
Dynamic initialization:
Example:
Note: not at the same time
Use static and dynamic initialization methods, that is, do not specify both the length of the array and the value of the array element during array initialization.
But the following code is executable
However, the reverse is not allowed. The way should be to re point STR to another memory address, and {"a" and "C"} are static initialization, which cannot be executed after array initialization.
The above commonplace talk about array initialization in Java is all that Xiaobian has shared with you. I hope it can give you a reference and support more programming tips.