Advertisement
ralphdc09

itf103.finals-wk-14-wk-18.number05

Jun 9th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. package md.WK14toWK18;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public class number05 {
  6.     public static void main(String[] args) {
  7.         int[] array = {5, 2, 7, 9, 6};
  8.         System.out.println("Original array : " + Arrays.toString(array));
  9.         for (int i = 0; i < array.length / 2; i++) {
  10.             int temp = array[i];
  11.             array[i] = array[array.length - i - 1];
  12.             array[array.length - i - 1] = temp;
  13.         }
  14.         System.out.println("Reverse array : " + Arrays.toString(array));
  15.     }
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement