veronikaaa86

06. Reverse Array of StringsLIST

Feb 4th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package Lists;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.ArrayList;
  7. import java.util.Collections;
  8. import java.util.List;
  9.  
  10. public class Demo {
  11.     public static void main(String[] args) throws IOException {
  12.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  13.  
  14.         String[] numsArr = reader.readLine().split("\\s+");
  15.  
  16.         List<String> myList = new ArrayList<>();
  17.        
  18.         Collections.addAll(myList, numsArr);
  19.         Collections.reverse(myList);
  20.  
  21.         System.out.println(String.join(" ", myList));
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment