import java.util.Random;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// Define initial array
String[] arr1 = {"a", "b", "c", "d", "e", "f"};
int size = arr1.length; // Current size of the array
// Create an instance of Random
Random r = new Random();
// Pick a random index to remove
int indexToRemove = r.nextInt(size);
System.out.println("Element to remove: " + arr1[indexToRemove]);
// Print the array before removing the element
System.out.println("Before removal: " + Arrays.toString(Arrays.copyOfRange(arr1, 0, size)));
// Remove the element at the random index by shifting elements
for (int i = indexToRemove; i < size - 1; i++) {
arr1[i] = arr1[i + 1]; // Shift elements to the left
}
// Reduce the size of the array
size--;
// Print the array after removing the element
System.out.println(" After removal: " + Arrays.toString(Arrays.copyOfRange(arr1, 0, size)));
}
}