Computer Science, asked by neelptl20702, 19 days ago

Use Array Methods in Java to Remove the middle element, if array length is odd or middle two elements when the length is even.

Answers

Answered by uditkhattry
0

Explanation:

public static void removeMiddle(int[] arr) { int size = arr.length; if(size % 2 ==0) { int x = arr.length/2 -1; for(int i = x; i <= arr.length - 2; i++) { arr[i] = arr[i + 2]; } } else { int z = arr.length/2; for(int i = z; i < arr.length - 1; i++) { arr[i] = arr[i + 1]; } }

Similar questions