What is the default initialization of an array in Java?

后端 未结 7 731
我在风中等你
我在风中等你 2020-11-22 16:30

So I\'m declaring and initializing an int array:

static final int UN = 0;
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
    arr[i] = UN;
}
<         


        
相关标签:
7条回答
  • 2020-11-22 16:55

    According to java,

    Data Type - Default values

    byte - 0

    short - 0

    int - 0

    long - 0L

    float - 0.0f

    double - 0.0d

    char - '\u0000'

    String (or any object) - null

    boolean - false

    0 讨论(0)
提交回复
热议问题