Mega Code Archive

 
Categories / Java Tutorial / Collections
 

How to define an Array

An array is a named set of same-type variables. Each variable in the array is called an array element. The first element will have an index of 0. public class MainClass {   public static void main(String[] arg) {     int[] intArray = new int[10];     for (int i = 0; i < 10; i++) {       intArray[i] = 100;     }     for (int i = 0; i < 10; i++) {       System.out.println(intArray[i]);     }   } } 100 100