-2

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.

2 Answers2

0

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.

Nim
  • 13
  • 1
  • 5
0

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.

Renuka Deshmukh
  • 998
  • 9
  • 16