Since an array has a fixed size that is allocated when created, your only option is to create a new array without the element you want to remove.
If the element you want to remove is the last array item, this becomes easy to implement using Arrays.copy
:
int a[] = { 1, 2, 3};
a = Arrays.copyOf(a, 2);
After running the above code, a will now point to a new array containing only 1, 2.
Otherwise if the element you want to delete is not the last one, you need to create a new array at size-1 and copy all the items to it except the one you want to delete.
The approach above is not efficient. If you need to manage a mutable list of items in memory, better use a List. Specifically LinkedList
will remove an item from the list in O(1)
(fastest theoretically possible).