in a static array, no.
To do it though you need to process little bit: you need to have a new array and then search that element which you need to remove in the old array and then you ignore putting this element in the new array.
the new array size will be old array size-1.
however, in arraylist, you dont worry about these and just use remove(int index). Please check http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html
hope this helps
no array api for remove
you can assign the index to null, leaving a null in the array, but you probably want the rest of the array to shift
you can manually provide the shift by creating a new array that is sized 1 smaller than the original, then copy each index from the original array into the new array, skipping the index to be removed
you may want to use Arraylist instead, it has a remove(int)
> Hi all,
> Is it possible to remove an element from an array at
> a particular index, suppose i have an array which has
> 20 elements and i wanna remove the element at
> position 2 , can i remove that, please provide me an
> answer, thanks in advance.
> Bye n TC
You can't remove elements from an array. You can
* Mark the element as unused, either with a special value that can't be "real" in your application or with a java.util.BitSet keeping track of used/not used.
* Copy the array's contents to a new, smaller array. (Bad idea if you'll be removing a lot of elements one by one.)
* Use a List, such as ArrayList or LinkedList. http://java.sun.com/docs/books/tutorial/collections/