慕婉清0372823
2018-07-19 17:00
class Telphone
{
private float screen;
private float cpu;
private float mem;
public float getScreen()
{
return screen;
}
public void setScreen(float newScreen)
{
screen=newScreen;
}
public Telphone()
{
System.out.println("无参");
}
public Telphone(float newScreen,float newCpu,float newMem)
{
screen=newScreen;
cpu=newCpu;
mem=newMem;
System.out.println("有参");
}
}
class InitailTelphone
{
public static void main(String[] args)
{
Telphone phone=new Telphone();
Telphone phone2=new Telphone(5.0f,1.4f,2.0f);
phone2.setScreen(6.0f);
System.out.println("screen:"+phone2.getScreen());
}
}
这些代码一点问题没有!如果你报错那就是你把他们都写道一个类中了。
public Telphone()没有指定类型 public void Telphone()
Java入门第二季 升级版
530652 学习 · 6091 问题
相似问题