Created
October 23, 2017 16:45
-
-
Save PocasPedro/3ac76bfe328c866c7d1708cab5dffb2f to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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