第一个对象pd对象提示要参数 然后为什么set方法需要创建字段?初学者,求大神
public class Hi{
private float screen;
private float cpu;
private float mem;
public float getScreen(){
return screen;
}
public void setScreen(float newScreen){
screen=newScreen;
}
public Hi(float screen,float cpu,float mem){
if(screen<3.5f){
System.out.println("您输入有误,自动赋值");
screen=3.5f;
}
screen=screen;
cpu=cpu;
mem=mem;
System.out.println("有参数的方法实现了"+cpu+""
+ " "+screen);
}
}
public class Hello {
public static void main(String[] args) {
Hi pd = new Hi();
Hi pd2= new Hi(2.1f,2.2f,3.0f);
// TODO 自动生成的方法存根
pd2.setScreen=(5.5f);
System.out.println(pd2.getScreen());
}
}