Java接口实现问题

art*_*ros 0 java inheritance implementation interface

我有一点问题.

第ll类:

interface jj{
    public class ll implements gg{
    public static String j ="C:\\";
        //some code here
}
}
Run Code Online (Sandbox Code Playgroud)

班级ggg:

interface gg{
public class ggg extends JFrame implements jj{
               //bunch of code + a textfield
        textField = new JTextField();
        textField.setBounds(72, 120, 217, 20);
        textField.setColumns(10);
               //bunch of code
}
}
Run Code Online (Sandbox Code Playgroud)

CLass aaa

public class aaa implements jj, gg {
    public aaa(){

//File chooser here + editing strin "j" from class "ll"
        File f = chooser.getSelectedFile();



        if(f!=null)
        {
            jj.ll.j = f.getPath(); 
                //And printing "j" string to the text field from ggg class
            gg.ggg.textField.setText(jj.ll.j);
        }
}
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,文本字段打印不起作用.我尝试使用System.out.println jj.ll.j字符串来测试它是否有东西.是的,它有和预期的工作方式.

Phi*_*Lho 5

我没有在界面中创建类的逻辑.

如果您需要各种类中的j字符串,只需将其声明为某个类中的公共静态字段.实现接口以获得常量是非常古老的.如果使用Java 1.5+,请执行静态导入.