Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

remove a object...

Thread view: 
tony - 08 Feb 2006 16:00 GMT
hi

i have a object Test and i have a array with many of their object

Test TestArray[20]...

how to remove a object from this array?

thanks
Thomas Weidenfeller - 08 Feb 2006 16:12 GMT
> Test TestArray[20]...
>
> how to remove a object from this array?

Remove as in "the objects after the one removed should move up one
position in the array"?

If yes, the hard way is to either use a loop or arraycopy. If you also
want to shrink the array's size, you can't.

The better way is to use a class like ArrayList, which has the necessary
code already implemented.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Oliver Wong - 08 Feb 2006 16:13 GMT
> hi
>
[quoted text clipped - 5 lines]
>
> thanks

   You could set the corresponding entry in the array to null.

   - Oliver
Roedy Green - 08 Feb 2006 16:29 GMT
>i have a object Test and i have a array with many of their object
>
>Test TestArray[20]...
>
>how to remove a object from this array?

see http://mindprod.com/jgloss/arraylist.html#REMOVING
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 09 Feb 2006 06:57 GMT
On Wed, 08 Feb 2006 16:29:38 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>>how to remove a object from this array?
>
>see http://mindprod.com/jgloss/arraylist.html#REMOVING

In case it is not obvious, you convert you array to ArrayList first,
also handled in that essay, and converting it back if necessary.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.