Created
July 25, 2014 02:39
-
-
Save jstitch/813b9cf0807399014e75 to your computer and use it in GitHub Desktop.
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
class ArrayDemo { | |
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; | |
System.out.println("Element at index 0: " | |
+ anArray[0]); | |
System.out.println("Element at index 1: " | |
+ anArray[1]); | |
System.out.println("Element at index 2: " | |
+ anArray[2]); | |
System.out.println("Element at index 3: " | |
+ anArray[3]); | |
System.out.println("Element at index 4: " | |
+ anArray[4]); | |
System.out.println("Element at index 5: " | |
+ anArray[5]); | |
System.out.println("Element at index 6: " | |
+ anArray[6]); | |
System.out.println("Element at index 7: " | |
+ anArray[7]); | |
System.out.println("Element at index 8: " | |
+ anArray[8]); | |
System.out.println("Element at index 9: " | |
+ anArray[9]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment