Advertisement
Spocoman

04. Reverse Array of Strings

Oct 20th, 2024
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3. import java.util.Collections;
  4.  
  5. class Main {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String[] arr = Arrays
  10.                 .stream(scanner.nextLine().split(" "))
  11.                 .toArray(String[]::new);
  12.        
  13.         Collections.reverse(Arrays.asList(arr));
  14.  
  15.         System.out.println(String.join(" ", arr));
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement