亲测、
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);
}