The Artima Developer Community
Sponsored Link

Java Answers Forum
(newbie) delete record from array..

2 replies on 1 page. Most recent reply: May 5, 2002 4:52 PM by neil

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
neil

Posts: 5
Nickname: neil
Registered: May, 2002

(newbie) delete record from array.. Posted: May 5, 2002 10:50 AM
Reply to this message Reply
Advertisement
Basically, I'm wanting to delete a record from an array, I have attempted it but don't think it is the right/proper way. I attached all the java files for anyone in a zip at http://www.guff.org/java.zip [9K] (well commented) - sorry i couldn't paste a snippet of the code, it's just i'm using 3 different classes

...also when you delete the record, let's say record 3 out of a number of 5 records or something, it deletes 3 and keeps 1, 2, 4, 5 instead of moving the list down to 1, 2, 3, 4. see what I mean?

What I'm doing is a printer queue demo, and would really really be grateful if anyone could give me a hand.. preferably edit the one I've got in the zip (to fix it up etc) or show me some code on this.

::post a reply or email me::, which ever you feel best.

Thanks for any replies


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: (newbie) delete record from array.. Posted: May 5, 2002 11:53 AM
Reply to this message Reply
Look at the code here:
http://www.quantumhyperspace.com/SourceBank/ArrayPlay.java
It may be just what you are looking for.

What you need to do is create a new array from the old one by adding all elements except the one you are deleting. The new array would be one less in size.
Then reassign the new array to the old reference.

neil

Posts: 5
Nickname: neil
Registered: May, 2002

Re: (newbie) delete record from array.. Posted: May 5, 2002 4:52 PM
Reply to this message Reply
Thanks alot, that helps me alot!

Flat View: This topic has 2 replies on 1 page
Topic: java telephony api defaultJTapiPeer.class Previous Topic   Next Topic Topic: JTree

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use