0

I know that following similar thing is possible:-

  • to delete a character from an array(by replacing with bblank space)
6
  • Deleting an index!?! Arrays are stored in contiguous memory locations, how can you delete an index from somewhere in between that range? Commented Feb 23, 2015 at 4:01
  • In java array is of fixed lengths, you cant delete index of aa array Commented Feb 23, 2015 at 4:02
  • you should look into ArrayList instead. you could assign null to the index like array[index]=null i suppose. your questions ambiguous. Commented Feb 23, 2015 at 4:02
  • 1
    Not sure if it accomplishes what you're asking, but you could create a new array, the size being 1 smaller, and add the values you wish to the new array. Commented Feb 23, 2015 at 4:13
  • I don't think he really wants to delete the index, just replace it by blank space. Commented Feb 23, 2015 at 4:13

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Not just Java, you just cannot delete an array's index in any language whatsoever!
1

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] = ' ';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.