Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Java 是否保证数组初始化?
假设我使用代码char[] uuid = new char[36];,是否可以保证每个元素都被初始化为 0?
char[] uuid = new char[36];
是的。JLS §10.3确保数组的所有元素都设置为其初始值,JLS §4.12.5保证其为0、false或null。
0
false
null
是的,它确实保证了初始化。JLS 第 10.3 节