OneBite.Dev - Coding blog in a bite size

declare an array in java

Code snippet on how to declare an array in java

  int[] array1 = new int[5];

This code declares an array of integers in Java, containing five elements. The first part of the code “int[] array1” declares an array object with the name “array1”. The second part “new int[5]” states that there should be five elements in the array and that these elements will be of the integer data type. The two parts together create an integer array of size five and store it in the “array1” variable.

java