有人可以幫我修復我的代碼嗎?我嘗試使用二維數組Java:不兼容的類型:java.lang.String不能轉換爲int
public class Tri {
public static void main(String [] args){
int rows;
int columns;
int i,j;
int [][] arrayNumbers = new int[5][5];
arrayNumbers[0][0] = " ";
arrayNumbers[1][0] = " ";
arrayNumbers[2][0] = "*";
arrayNumbers[3][0] = " ";
arrayNumbers[4][0] = " ";
arrayNumbers[0][1] = " ";
arrayNumbers[1][1] = "*";
arrayNumbers[2][1] = "*";
arrayNumbers[3][1] = "*";
arrayNumbers[4][1] = " ";
arrayNumbers[0][2] = "*";
arrayNumbers[1][2] = "*";
arrayNumbers[2][2] = "*";
arrayNumbers[3][2] = "*";
arrayNumbers[4][2] = "*";
arrayNumbers[0][3] = " ";
arrayNumbers[1][3] = "*";
arrayNumbers[2][3] = "*";
arrayNumbers[3][3] = "*";
arrayNumbers[4][3] = " ";
arrayNumbers[0][4] = " ";
arrayNumbers[1][4] = " ";
arrayNumbers[2][4] = "*";
arrayNumbers[3][4] = " ";
arrayNumbers[4][4] = " ";
for(i=0;i<rows;i++){
for(j=0;j<columns;j++) {
System.out.print(arrayNumbers[i][j] + " ");
}
System.out.println(" ");
}
}
}
一起組成一個三角形,但我不斷收到錯誤消息「的Java:不兼容的類型:java.lang.String中不能轉換成int
任何想法,我」要去錯了嗎?口口聲聲說,它需要一個int,但只找到一個String