0
java collection in reverse
Use the ArrayList called reversedLanguages. Use a loop to fill reversedLanguages with the same items as languages, except in reverse order. here is what I got: what I am missing? import java.util.ArrayList; class Main { public static String[] languages = {"English", "Spanish", "Japanese", "Italian", "Russian"}; public static ArrayList<String> reversedLanguages; public static void main(String[] args) { reversedLanguages = new ArrayList<String>(); // Write your code below here for(int i = 0; 0 <= languages.length; --i) } }
1 Resposta
+ 3
for(int i = languages.length -1; i>=0; i--) {
reversedLanguages.add(languages[i]);
}
https://code.sololearn.com/c23mn6QvXb6C/?ref=app