0
How to delete an element from an array?
4 Answers
+ 1
Basic Java arrays are fixed length, you cannot remove elements. Try using an ArrayList instead.
+ 1
As John indicates basic arrays can't be resized. This answer describes a function you can use to create a new array without the element, and also indicates ArrayList:
http://stackoverflow.com/a/4870214/3981745
+ 1
I skipped ArrayUtils because you're importing an entire library to do something better done directly.
http://stackoverflow.com/a/4870274/3981745
"There are alternatives in the form of 3rd-party libraries (e.g. Apache Commons ArrayUtils), but you may want to consider whether it is worth adding a library dependency just for the sake of a method that you could implement yourself with 5-10 lines of code."
... or just use a list.
0
array = ArrayUtils.removeElement(array, element)