Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Arrays.fill的問題~~

public class Arrayfill{

public static void main(String[] args){

int[][] A = new int[5][6];

for (int i = 0; i < A.length; i++) {

Arrays.fill(A[i], -1);

}

for (int i = 0; i < A.length; i++) {

for(int j=0;j<A[i].length;j++){

System.out.print(A[i][j]);

}

}

}

}

====

symbol : variable Arrays

location: class Arrayfill

Arrays.fill(A[i], -1);

^

1 error

=======

why?

1 Answer

Rating
  • 2 decades ago
    Favorite Answer

    import java.util.Arrays; //你忘了這行了

    public class Arrayfill{

    public static void main(String[] args){

    int[][] A = new int[5][6];

    for (int i = 0; i < A.length; i++) {

    Arrays.fill(A[i], -1);

    }

    for (int i = 0; i < A.length; i++) {

    for(int j=0;j<A[i].length;j++){

    System.out.print(A[i][j]);

    }

    }

    }

    }

    Source(s): me
Still have questions? Get your answers by asking now.