Could someone give me a very elementary example in doing this?
I'm trying to write a method that takes something looks inside an array and remove a specific element from within the array at index i.
Could someone give me a very elementary example in doing this?
I'm trying to write a method that takes something looks inside an array and remove a specific element from within the array at index i.
You could set the array item to null, or use ArrayUtils'
array = ArrayUtils.removeElement(array, element)
you could also fill it with a blank value of the array type. This is a very abstract question with many answers, but google is your friend.
Arrays have fixed size so deleting an element would be a costly operation.
Method 1: create a new array of size length -1 and copy all elements except the one you want to delete.
Method 2: Use ArrayList instead of arrays.