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) } }

3rd Apr 2019, 11:43 PM
Albert Yakubov
Albert Yakubov - avatar
1 ответ
+ 3
for(int i = languages.length -1; i>=0; i--) { reversedLanguages.add(languages[i]); } https://code.sololearn.com/c23mn6QvXb6C/?ref=app
4th Apr 2019, 9:17 AM
Tibor Santa
Tibor Santa - avatar