我正在尝试从创建列表的那个类的不同类中调用函数列表。我的意思是
public class FUNCTION {
String fichier=null;
int nb_link_func=-1;
String fonc_nom=null;
int [] list_id=null;
public FUNCTION() {
};
};
/////////////
public class CODE {
FUNCTION [] fonctions;
public CODE (String tree_file) {
// I fill the variable list_id up, the list of functions
};
}
/////////////
public class Tree extends JTree {
CODE code=null;
private JTree tree;
String fname=null;
public Tree (String tree_file,DefaultMutableTreeNode top) {
super(top);
code=new CODE(tree_file);
fname=fonctions[1].getNom(); //This returns cannot find symbol fonctions
};
};
它返回“找不到符号功能”有错误但我找不到它
答案 0 :(得分:0)
那是因为类Tree
的构造函数没有fonctions[]
数组的可见性。您需要使用类CODE
的对象,这是“代码”。所以而不是:
fname=fonctions[1].getNom();
尝试:
fname=code.fonctions[1].getNom();
答案 1 :(得分:0)
首先公开宣传:
(car L)
并改变:
public FUNCTION [] fonctions;
为:
fname=fonctions[1].getNom();