1 回答
TA贡献1条经验 获得超0个赞
//我的输出就是6.0啊
package imook;
public class Telphone {
float Screen;
float op;
float lp;
public Telphone(){
}
public Telphone(float Screen,float op,float lp){
this.lp=lp;
this.op=op;
this.Screen=Screen;
}
protected float getScreen() {
return Screen;
}
protected void setScreen(float screen) {
Screen = screen;
}
protected float getOp() {
return op;
}
protected void setOp(float op) {
this.op = op;
}
protected float getLp() {
return lp;
}
protected void setLp(float lp) {
this.lp = lp;
}
}
****************************************************************************************
package imook;
public class InitailTelphone {
public static void main(String[] args) {
// TODO 自动生成的方法存根
//通过无参构造方法可以创建对象
Telphone phone=new Telphone();
//通过有参构造方法可以创建对象
Telphone phone2=new Telphone(5.0f,1.4f,2.0f);
phone2.setScreen(6.0f);
System.out.println("screen:"+phone2.getScreen());
}
}
添加回答
举报