且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java:原始数组——它们是否已初始化?

更新时间:2023-11-26 20:30:46

15.10 数组创建表达式 JLS 说

[...] 创建指定长度的一维数组,并将数组的每个组件初始化为其默认值

[...] a single-dimensional array is created of the specified length, and each component of the array is initialized to its default value

以及 4.12.5 变量的初始值 它说:

对于类型int,默认值为0,即0.

For type int, the default value is zero, that is, 0.