Last active
December 20, 2015 14:09
-
-
Save dhust/6144568 to your computer and use it in GitHub Desktop.
An example of associative arrays. That means there are two arrays where the elements are related (associated) to one another.
This file contains hidden or 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 static void main(String[] args) { | |
| String[] artist = {"Snoop Dogg", "Justin Bieber", "Hoodie Allen", "Taylor Swift" }; | |
| int[] ages = { 41, 18, 23, 22 }; | |
| for (int i=0; i<artist.length; i++) { | |
| System.out.println(artist[i] + " is " + ages[i] + " years old."); | |
| } | |
| } | |
| /* OUTPUT: | |
| Snoop Dogg is 41 years old. | |
| Justin Bieber is 18 years old. | |
| Hoodie Allen is 23 years old. | |
| Taylor Swift is 22 years old. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment