If you would like to print five numbers from an array, one after another, you can do this by using a "for loop" to print the numbers to the screen, assuming they were already stored in the array.
Here's what some Java code would look like to print the numbers one to five, stored in an array with five indices.
public class PrintArray{
public static void main(String [] args){
//create a new array of type "int" with five indices (0-4) to hold five integers
int[] intArray = new int[5];
//manually add some values to the array (this can be done using a "for loop", as well)
intArray[0] = 1;
intArray[1] = 2;
intArray[2] = 3;
intArray[3] = 4;
intArray[4] = 5;
//Now that we have added five integers to our array, we can print it using a "for loop", rather than
//having to write five separate "System.out.println()" statements
for(int i = 0; i <= 4; i++){
//print out the value stored in the "ith" index of the "intArray" array
System.out.println(intArray[i]);
}
}
}
Alternatively, here's a link to the above code on PasteBin.com, which can be viewed with proper formatting and syntax highlighting.
http://pastebin.com/JHnQdtUg
One thing to note, however, is that if you are required to get the numbers to be stored in the array from a user, you could do this using the "Scanner" class, which is in the "java.util" library.
Best of luck and I hope I helped you!