Java. Create array

Array declaration

In java we usually declare arrays like this:

Initializing after array declaration

Once an array is declared we have to fill all array’s values

array[0] = "value 0";

array[1] = "value 1";

Fill array with same value

If you want to fill an array with the same value you can use java.utils.Arrays’s fill method

Declaration and initializing at the same time

We can also declare and fill values at the same time

You may also find these posts interesting: