Advertisement
Kancho

Rversly_Read_Array

Mar 6th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Soft_Uni_Arrays {
  4. public static void main(String[] args) {
  5.  
  6. Scanner sc = new Scanner(System.in);
  7. System.out.println("Array"); // enter Array.
  8.  
  9. String [] family = sc.nextLine().split(" "); // read the array's symbols.
  10.  
  11. for (int i = 0; i < family.length / 2; i++) { // perambulate all symbols of the array divided by 2 because we work with pairs.
  12. String temporaryFamily = family[i];// create new temp string to store the interchanges.
  13. family[i] = family[family.length -i -1]; //read the Array family reversely.
  14. family[family.length -i -1] = temporaryFamily; // abstract the reversely read temporary array to original one.
  15. }
  16. System.out.println(String.join(", ", family));
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement