I'm writing code for a small monster game based on 2DArray. But I can't proceed further until ArrayStoreException get handled. I want to do the following task by using java.util.Arrays & Arrays.fill. Don't suggest another way. Just want to resolve this. Any help would be highly appreciated. Thanks in advance....
package PlayWithStars;
import java.util.Arrays;
public class Monster {
static char battleBoard[][] = new char[10][10];
public void buildBattleBoard() {
for (char[] row : battleBoard) {
Arrays.fill(battleBoard,'*');
}
}
public void redrawBoard() {
for (int k=1 ; k<=30 ; k++) { //
System.out.print("-"); // to print ------------------
} //
System.out.println();
for (int i = 0; i < battleBoard.length; i++) {
for (int j = 0; j < battleBoard[i].length; j++) {
System.out.println("|"+battleBoard[i][j]+"|");
}
System.out.println("");
for (int k=1 ; k<=30 ; k++) { //
System.out.print("-"); // to print ------------------
} //
}
public static void main(String[] args) {
Monster m = new Monster();
m.buildBattleBoard();
}
}