Reverse Order of Array

Run Settings
LanguageJava
Language Version
Run Command
public class ReverseOrder { public static void main(String[] args){ String[] cities = {"Atlanta", "Charlotte", "Dallas", "Los Angeles", "New York", "Orlando", "Philadelphia", "Seattle"}; /*reverse the order of the array below */ String[] temp = {" ", " ", " ", " ", " ", " ", " ", " "}; for(int i=0; i<cities.length - 1; i++) { temp[i] = cities[cities.length - i - 1]; } // for (int i = 0; i < temp.length; i++){ // System.out.println(temp[i]); // } for (int i = 0; i < cities.length; i++){ cities[i] = temp[i]; } //print the result for (int i = 0; i < cities.length; i++){ System.out.println(cities[i]); } } }
Editor Settings
Theme
Key bindings
Full width
Lines