Results 1 to 3 of 3
Thread: emptying/clearing an array
- 08-09-2010, 12:49 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 6
- Rep Power
- 0
emptying/clearing an array
public void removePlayers(Player[] client)
{
String G = "";
for (int i = 0; i < numPlayers; ++i)
{
G = G + client[i];
}
JOptionPane.showMessageDialog(null, G, "Player Info", 1);
}
i have set up this fubction as i want to clear all the data in the array. the info is all brought forward with the string and i want to be able to clear this wen sent back.
either code or a button that will be able to clear this will work. i have ran into so many walls and cannot solve it.
any help will be gretfully accepted,
thank you
- 08-09-2010, 01:17 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,588
- Blog Entries
- 7
- Rep Power
- 17
You can either make that method return (another) empty Player array (and have the caller of that method accept that, as in:
or you can wipe out all the elements of the existing array in your method:Java Code:Player[] client= ...; // values in here client= removePlayers(client); ... Player[] removePlayers(Player[] client) { ... return new Player[numPlayers]; // return empty array }
kind regards,Java Code:void removePlayers(Player[] client) { ... for (int i= 0; i < numPlayers; i++) client[i]= null; }
Jos
- 08-09-2010, 01:39 PM #3
Similar Threads
-
convert byte array into char array
By kgkamaraj in forum New To JavaReplies: 4Last Post: 09-13-2011, 11:32 AM -
Help Clearing BufferedImage
By ketann in forum Java 2DReplies: 19Last Post: 03-29-2010, 07:45 PM -
Help needed Clearing the contents of a File
By sandeepsai17 in forum New To JavaReplies: 5Last Post: 07-02-2009, 02:31 PM -
How to add an integer to a array element and the store that backinto an array.
By Hannguoi in forum New To JavaReplies: 1Last Post: 03-31-2009, 06:40 AM -
MouseListener - clearing a textField when clicked on?!
By sailor_girl in forum AWT / SwingReplies: 4Last Post: 03-01-2009, 05:01 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks