I have an array of integers in Java that is initialized as follows:
public int MyNumbers[] = {0,0,0,0};
I would like to, however, initialize the array to a variable-length number of zeroes.
private int number_of_elements = 4;
public int MyNumbers[] = {0} * number_of_elements; // ????
I am clueless how to do this being new to Java coming from C. Any suggestions?
EDIT
I know I could use a for
loop, but I hoping there was a simple way to do it.