Java - remove an element from an array
How do I remove a particular string or int object from an array in java?The best choice is to use a collection of objects. The elements are copied to the same array with a position offset of -1.
public void removeElement(Object[] a, int del) {
System.arraycopy(a,del+1,a,del,a.length-1-del);
}
Apache Commons
You can also use the commons lang's libraryArrayUtils.array = ArrayUtils.removeElement(array, element)Resources:
https://stackoverflow.com/questions/642897/removing-an-element-from-an-array-java