Skip to content

Instantly share code, notes, and snippets.

@PocasPedro
Created October 23, 2017 16:45
Show Gist options
  • Save PocasPedro/3ac76bfe328c866c7d1708cab5dffb2f to your computer and use it in GitHub Desktop.
Save PocasPedro/3ac76bfe328c866c7d1708cab5dffb2f to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 13
public class ArrayDemoWithLoop {
public static void main(String[] args) {
// declares an array of integers
int[] anArray;
// allocates memory for 10 integers
anArray = new int[10];
// initialize first element
anArray[0] = 100;
// initialize second element
anArray[1] = 200;
// and so forth
anArray[2] = 300;
anArray[3] = 400;
anArray[4] = 500;
anArray[5] = 600;
anArray[6] = 700;
anArray[7] = 800;
anArray[8] = 900;
anArray[9] = 1000;
for( int i = 0 ; i < 10 ; i++ ){
System.out.println("Element at index: " + i + " is " + anArray[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment