Languages
[Edit]
EN

Java - default array values

0 points
Created by:
Warren-X
443

In this article, we would like to show you what are default array values initialized by the compiler when you don’t assign values to array elements in Java.

Quick solution:

DatatypeDefault value
int0
float0.0
double0.0
booleanfalse
Stringnull
byte0

 

Practical example

Edit

In this example, we create one-element, not initialized arrays to see what is the default value for each type. 

Output:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - Arrays (popular problems)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join