CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    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);

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: Not able to clear data in 2d array

    i get an error

    Please show the error and/or explain
    Norm

  3. #3
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Not able to clear data in 2d array

    Also, please post all the code and use code tags.

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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 code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured