Created
November 18, 2019 13:15
-
-
Save 51enra/1cf862a505c418d80c5148c37324ff8d to your computer and use it in GitHub Desktop.
Quest 4: Arrays and Loops
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 Movies { | |
public static void main(String[] args) { | |
String[] movieNames = { "Raiders of the Lost Ark", "Indiana Jones and the Temple of Doom", | |
"Indiana Jones and the Last Crusade" }; | |
String[][] movieMainActors = new String[][] { { "Harrison Ford", "Karen Allen", "Paul Freeman" }, | |
{ "Harrison Ford", "Kate Capshaw", "Ke Huy Quan" }, | |
{ "Harrison Ford", "Sean Connery", "Denholm Elliot" } }; | |
String actorString; | |
for (int i = 0; i < movieNames.length; i++) { | |
actorString = ""; | |
for (String actor : movieMainActors[i]) { | |
actorString += (actor + ", "); | |
} | |
actorString = actorString.substring(0, actorString.length()-2) + "."; | |
System.out.println("In the movie " + movieNames[i] + ", the main actors are: " + actorString); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment