Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ReverseArrays {
- static void revArrays(String[] arr) {
- for(int i = 0; i < arr.length / 2; i++){
- String temp = arr[i];
- arr[i] = arr[arr.length - 1 - i];
- arr[arr.length - 1 - i] = temp;
- }
- }
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String value = scan.nextLine();
- String[] arr = value.split(" ");
- revArrays(arr);
- for (int i = 0; i < arr.length; i++) {
- System.out.print(arr[i] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement