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);
Printable View
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);
i get an error
Please show the error and/or explain
Also, please post all the code and use code tags.
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);
}