int Array Java

int Array Java

Apart char and string arrays, the most commonly used array is int Array in coding.

Following code on int Array shows the initialization and declaration of an integer array and printing its elements.

int Array

int marks[] = {40, 50, 60, 70, 80};

In the above statement, an int array is initialized. Initialization is nothing but declaration of array and assigning the values to elements goes at a time.

int grades[] = new int[3];
grades[0] = 1;
grades[1] = 2;
grades[2] = 3;

The other way of initialization is declaring array and giving the values each element. grades int array is created with new keyword with three elements. All the three are given values.

Know all the other array operations: All Array Operations at a Glance

Leave a Reply

Your email address will not be published. Required fields are marked *