Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

plz help

 
jeyakanth yogaratnam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to know hw to update or delete records from a array.if u have the code plz send me it is urgent.thanks
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

An array of...?

Depending on your needs, this could be as simple as assigning a new value, or null, to an array element; or it might involve copying higher-number elements down to fill up a "hole" left by a deleted element. Can you describe your requirements in a bit more detail?
 
jeyakanth yogaratnam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well it is like this that i want ot create an array of objects and store data in it. and after that i want to update that record and amle to delete it as well. this is my problem. i am able to add records but don't knoew to update or to delete it. if u can help me it will be a big help.

thank you
jeyakanth
 
Node King
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using an ArrayList:

Here is the API:
http://java.sun.com/j2se/1.3/docs/api/java/util/ArrayList.html

You can use those methods to remove Objects. Don't forget to import java.util.ArrayList!

Oh, and failing that, my advice is to replace the old array with a brand new array one place smaller and without the data you wished to delete. Copy all the elements across using a while or for loop.

If you need more help let us know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic