封裝的話直接這樣寫不行嗎?
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);
}
2017-01-05
可以,把 main 函數(shù)放在 Phone類里面
2017-03-14
懵比,為什么要把main函數(shù)放在Phone類里面
2017-01-11
可以,把 main 函數(shù)放在 Phone類里面
2017-01-05
要把 main 函數(shù)放在 Phone類里面
2017-01-05
這樣可以