【发布时间】:2015-12-15 07:12:12
【问题描述】:
Eclipse 说:'chiffres 无法解析为变量',如何修复调用方法?
public class Table {
public static void main(String[] args) {
Tableau1 table = new Tableau1();
table.CreerTable();
table.AfficherTable(chiffres);
}}
部分: 和 class Tableau1 with array: 来声明它
public class Tableau1 {
int [][] chiffres;
int nombre;
public void CreerTable(){
int[][] chiffres= {{11,01,3},
{12,02,4},
{12,03,5}};
//edited
this.chiffres=chiffres;
}
public int[][] AfficherTable(int[][] chiffres){
this.nombre=12;
for(int i=0;i<2;i++){
System.out.println("essai"+chiffres[i][1]);
if(chiffres[i][0]==nombre){System.out.println("ma ligne ="+chiffres[i][0]+","+chiffres[i][1]+","+chiffres[i][2]);
};
}
return chiffres;
}
}
非常感谢
【问题讨论】:
-
是的,它是什么,在哪里声明?
-
抱歉我贴了两次
-
您忘记声明变量“chiffres”了吗?我在你的主要方法中没有看到它。
-
@chris_cx 变量需要在使用前声明。你在代码中声明它的位置?
-
那是你的完整代码吗?!我没有看到任何关于 chiffres 的声明?!是 Tableau1 中的类型吗?!还是一堂课?!