62,623
社区成员
发帖
与我相关
我的任务
分享
public class Person{
public boolean makeCall(long number){
Mobile mobile=new Mobile();
return mobile.dialUp(number);
}
}
public Interface MobileInterface{
public boolean dialUp(long number);
}
public class Person{
private MobileInterface mobileInterface;
public boolean makeCall(long number){
return this.mobileInterface.dialUp(number);
}
public void setMobileInterface(MobileInterface mobileInterface){
this.mobileInterface=mobileInterface;
}
}
<bean id="person" class="Person">
<property name="mobileInterface">
<ref local="mobileInterface"/>
</property>
</bean>
<bean id="mobileInterface" class="Mobile"/>