31/12/2021
Reverse Array : Reverse the given array by using temporary variable. Input : 50, 40, 30, 20, 10 Output : 10, 20, 30, 40, 50 /** * StrangeCoder */ public class ReverseArray { private static void reverse(int[] array, int length) { int reverseArray[] = new int[length]; int j = length; for (int i = 0; i < length; i++) { reverseArray[j-1] = array[i]; j = j - 1; } System.out.println("Printing reversed array : \n"); for (int i = 0; i < reverseArray.length; i++) { System.out.println(reverseArray[i]); } } public static void main(String[] args) { int array[] = {50, 40, 30, 20, 10}; reverse(array, array.length); } } …...
Reverse Array : Reverse the given array by using temporary variable. Input : 50, 40, 30, 20, 10 Output : 10, 20, 30, 40, 50 /** * StrangeCoder */ public class ReverseArray { private static …