ema
ema

Reputation: 79

Is it possible to delete index of an array in java?

I know that following similar thing is possible:-

Upvotes: 0

Views: 531

Answers (2)

Óscar López
Óscar López

Reputation: 236004

Just assign the blank space to the position of the character you want to replace - it's not a real deletion, an array in Java is of fixed length (it can't be resized):

array[index] = ' ';

Upvotes: 1

Anonymous Person
Anonymous Person

Reputation: 305

You cannot delete an index from an array. This is because arrays have a fixed length that cannot be changed. If you want a list which you can delete elements, check out the ArrayList class. Here is the documentation: http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

Upvotes: 1

Related Questions