封装的话直接这样写不行吗?
package 封装;
public class Phone {
private float mem;
private float cpu;
private float screen;
public void setScreen(float newScreen){
screen=newScreen;
System.out.println("screen:"+screen);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Phone one=new Phone();
one.setScreen(6.0f);
}