I have this code
public static Boolean freq[] = new Boolean[Global.iParameter[2]];
freq[Global.iParameter[2]] = false;
could someone tell me what exactly i’m doing wrong here and how would i correct it? I just need to initialize all the array elements to Boolean false.
thank you
Either use
boolean[]instead so that all values defaults tofalse:Or use
Arrays#fill()to fill the entire array withBoolean.FALSE:Also note that the array index is zero based. The
freq[Global.iParameter[2]] = false;line as you’ve there would causeArrayIndexOutOfBoundsException. To learn more about arrays in Java, consult this basic Oracle tutorial.