You can declare an array in Java in 3 different ways.

Sample Java

int[] myArr = new int[5];
int[] myArr = {1,2,3,4,5};
int[] myArr = new int[]{1,2,3,4,5};

4 thought on “How to declare an array in Java”

Leave a Reply