java中接口是否可以成为其他类的属性 有的话,请提供实例,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package t2;public class Button { /* * private Light light = new Light(); * * public void pressOn() * { light.turnOn(); } * * public void pressOff() { light.turnOff(); } */ public class Button { private Switch switch; public Button(Switch switch) { this.switch = switch; } public void pressOn() { this.switch.trunOn(); } public void pressOff() { this.switch.turnOff(); } }} Switch是一个接口,编译不通过 csdn首页的方法2:“凿壁借光”的模式场景实例运行错误 不管 Switch 是一个接口还是一个实例类,在Button的构造函数中,传入的那个Switch,肯定是一个实例类。 可以,示例发到你csdn邮箱你看看先 stringbuffer问题 用birt的牛人进啊,大家帮我看一个分组问题 帮忙调个小程序,谢谢各位老大 请教怎样获得鼠标双击的事件? C#转JAVA-up有分! ★】※【★全新论坛浏览工具★】※【★ 在jbuilder里,序列化的时候,是不是不支持中文的? 感谢希偌大哥的帮助, 先给分了!!! 我的JFrame的大小是1024*768,但其中的JPanel我想设为200*100就可以了,怎样设呢? jar问题 谁能给个jdk1.4的下载地址 如何来检测用户有一段时间没有动键盘鼠标了?
/*
* private Light light = new Light();
*
* public void pressOn()
* { light.turnOn(); }
*
* public void pressOff() { light.turnOff(); }
*/
public class Button
{
private Switch switch; public Button(Switch switch) {
this.switch = switch;
}
public void pressOn()
{
this.switch.trunOn();
}
public void pressOff()
{
this.switch.turnOff();
}
}
}
你看看先