import java.util.Arrays;
public class MyClass {
public static int[] remove(int[] arr, int key) {
return Arrays.stream(arr)
.filter(val -> val != key)
.toArray();
}
public static void main(String args[]) {
int[] arr = { 3, 2, 1, 3, 3, 7, 5, 4, 3, 3, 3, 3 };
int key = 3;
arr = remove(arr, key);
System.out.println(Arrays.toString(arr));
}
}
/*
run:
[2, 1, 7, 5, 4]
*/