veronikaaa86

06. Reverse Array of Strings

Feb 4th, 2018
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. package Arrays;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class Lab06_ReverseAnArrayOfString {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         String[] words = scanner.nextLine().split("\\s+");
  11.  
  12.         for (int i = words.length - 1; i >= 0; i--) {
  13.             System.out.print(words[i] + " ");
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment