SophiYo

ReverseArrayOfStrings

Feb 5th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package O3Arrays;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Ex04ReverseArrayOfStrings {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String input = scanner.nextLine();
  9.         String[] splitInput = input.split(" ");
  10.         String[] stringInput = new String[splitInput.length];
  11.  
  12.         for (int i = 0; i < splitInput.length; i++) {
  13.             stringInput[splitInput.length - i -1] = splitInput[i];
  14.         }
  15.  
  16.         for (int i = 0; i < splitInput.length; i++) {
  17.             System.out.print(stringInput[i] + " ");
  18.         }
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment