Saturday, 26 April 2014

Java: Array Tutorial

public class ArrayBasic
{
 public static void main(String[] args)
{
//Declare an int array of size 100
int[] array = new int[100];

//insert elements using for loop
for(int i= 0; i<=99; i++)
{
array[i] = i;
}

//display elements
for(int i = 0; i <=99; i++)
{
System.out.println("Index" + i + " =" + array[i]);
}
}
}

No comments:

Post a Comment