-
July 19th, 2010, 12:51 PM
#1
Not able to clear data in 2d array
When i recieved an error on the input from the user, the pop box gives them instruction to try again but i want the old data to clear out first. What i am trying is below, however i get an error when it runs::
java.util.Arrays.fill(myArray,0);
-
July 19th, 2010, 07:38 PM
#2
Re: Not able to clear data in 2d array
i get an error
Please show the error and/or explain
Norm
-
July 21st, 2010, 11:38 PM
#3
Re: Not able to clear data in 2d array
Also, please post all the code and use code tags.
-
July 22nd, 2010, 10:44 AM
#4
Re: Not able to clear data in 2d array
If your title is correct and your array is a 2D array then the Arrays.fill(..) method wont work because it take a 1D array as an argument and not a 2D array.
You need to have a loop iterating over the first dimension and calling the fill method for each 1D array ie
Code:
for ( int[] e : myArray )
{
Arrays.fill(e, 0);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|