this will help In Java, all array elements are automatically initialized to the default value. For primitive numerical types, that's 0 or 0.0. For booleans, that's false. For objects, that's null. In other languages such as C++, the values in an uninitialized array are undefined. Some compilers may initialize to 0/null similarly for security, and it's very bad practice to rely on this. However, this behavior is well defined in Java and so it's perfectly okay to create a primitive array and trust that the values are 0.