关于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技术的那些事
下一篇: 关于java的那些事