欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

关于java的那些事

程序员文章站 2022-05-05 08:55:33
...

亲测、

public class A implements D {
    public int id;
    public int name;
    public int a;

    public int getId() {
        return id;
    }
    @Override
    public void setId(int id) {
        this.id = id;
    }

    public int getName() {
        return name;
    }

    @Override
    public void setName(int name) {
        this.name = name;
    }

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    public static void main(String[] args) {
        A a = new A();
        a.setId(1);
        save(a);
    }

    private static void save(D a) {

    }


}

```java
public class B implements D {
    public int id;
    public int name;
    public int b;

    public int getId() {
        return id;
    }

    @Override
    public void setId(int id) {
        this.id = id;
    }

    public int getName() {
        return name;
    }

    @Override
    public void setName(int name) {
        this.name = name;
    }

    public int getB() {
        return b;
    }

    public void setB(int b) {
        this.b = b;
    }
}

public interface D {
    void setId(int id) ;

    void setName(int name);




}
相关标签: java