我是java新手,我有一个问题。假设我有这个代码:public class Number { private int[][] number; private int row; private int column; public Number(int[][] num) { this.row = num.length; this.column = num[0].length; this.number = new int[row][column]; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { number[i][j] = num[i][j]; } } } public Number(int row, int column) { this.row = row; this.column = column; number = new int[row][column]; } public Number getNewNumber() { Number newNumber = new Number(row, column); for (int i = 0; i < row; i++) { newNumber.number[i] = number[i]; } return newNumber; } public int getNewNumberSum() { Number newNumber = new Number(row, column); int sum = 0; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { newNumber.number[i][j] = number[i][j]; sum += newNumber.number[i][j]; } } return sum; }}我的问题是关于语法。可以在不同的方法上将对象的名称命名为相同的名称,而在不同的方法上将变量的名称命名为相同的名称吗?
添加回答
举报
0/150
提交
取消