我一直在尝试为我的CS类写一个程序,我有一个问题。在下面的代码中,我一直在initializeArray(firstArray)
和initializeArray(secondArray)
处获得错误消息。
消息显示the method initializeArray(int[][]) is undefined for type processArray
。有人能告诉我我哪里做错了吗?我需要能够调用方法initializeArray在我的processArray方法。
public class ProcessArray {
// The constructor for the class: it initializes the attributes "rows" and "columns", and also completes the
// declarations for the two arrays using the dimensions received. It then calls a private method in the class
// to set the values in both arrays to 0.
public ProcessArray (int rows, int columns){
int[][] firstArray = new int[rows][columns];
int[][] secondArray = new int[rows][columns];
initializeArray(firstArray);
initializeArray(secondArray);
}
// This private utility method sets the values in both arrays to 0.
private void intializeArray(int[][] array){
int rows = array.length;
int columns = array[0].length;
for(int i = 0; i < rows; i++){
array[i][0] = 0;
for(int j = 0; j< columns; j++){
array[i][j] = 0;
}
}
}
你打错字了:
intializeArray
initializeArray