initializing a boolean array in java

前端 未结 6 1066
花落未央
花落未央 2020-12-23 08:35

I have this code

public static Boolean freq[] = new Boolean[Global.iParameter[2]];
freq[Global.iParameter[2]] = false;

could someone tell m

6条回答
  •  独厮守ぢ
    2020-12-23 09:29

    The array will be initialized to false when you allocate it.

    All arrays in Java are initialized to the default value for the type. This means that arrays of ints are initialised to 0, arrays of booleans are initialised to false and arrays of reference types are initialised to null.

提交回复
热议问题