declare array with values java 1

declare array with values java

int[] myIntArray = new int[3];
int[] myIntArray = {1, 2, 3};
int[] myIntArray = new int[]{1, 2, 3};

Here is what the above code is Doing:
1. Declaring an array of integers.
2. Allocating memory for 3 integers.
3. Assigning the value 1 to the first element, 2 to the second element, and 3 to the third element of the array.
4. Declaring an array of integers and providing initial values.
5. Declaring an array of integers, allocating memory for 3 integers, and providing initial values.

Similar Posts