Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Lab4ReverseArrayStrings {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] arrInput = scanner.nextLine().split(" ");
- for (int i = 0; i < arrInput.length / 2 ; i++) {
- int contraIndex = arrInput.length -1-i;
- String temp = arrInput[i];
- arrInput[i] = arrInput[contraIndex];
- arrInput[contraIndex] = temp;
- }
- System.out.println(String.join(" ",arrInput));
- }
- }
- /* Write a program to read an array of strings, reverse it and print its elements.
- The input consists of a sequence of space separated strings. Print the output on a single line (space separated).
- */
Add Comment
Please, Sign In to add comment