斑竹新上任,请教一个程序结构问题,捧场......

NoWant 2001-03-13 02:13:00
斑竹新上任,请教一个程序结构问题,捧场......

其实是关于多重继承的,对接口理解不深,实施总有点别扭:

class A {
JTextField aText;
int aInt;
public void setText(JTextField newText) {
aText=newText;
}
public void setData(int newInt) {
aInt=newInt;
}
}
class A_son_1 extends A {
...
}
class A_son_2 extends B {
...
}

class B extends Frame {
JTextFiels aText;
int aInt;

A_son_1 aSon1=new A_son_1;
A_son_2 aSon2=new A_son_2;
C c=new C;

aText=c.initText(); //...
aInt=c.initInt(); //...
aSon1.setText(aText);
aSon2.setText(aText);
aSon1.setData(aInt);
aSon2.setData(aInt);
}

class C {
public JTextField initText() {
...
}
public int initInt() {
...
}
}

想让 class B 也同时 继承 class A.How to ?
怎样做更规范????






...全文
105 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
NoWant 2001-03-28
  • 打赏
  • 举报
回复
每人 深纠 只好 给分
NoWant 2001-03-26
  • 打赏
  • 举报
回复
有一点没明白, 接口 中是不能有实现代码的,

想有公用代码怎么办?

CSDN 慢!!!!
lhdyf 2001-03-13
  • 打赏
  • 举报
回复
class B extend Frame implements A
skyyoung 2001-03-13
  • 打赏
  • 举报
回复
接口可以多重继承,即类只能继承有一个父类和多个接口

81,115

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧