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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>