set,get方法对封装数据进行操作
例如:private float Screen
public void setScreen(float newScreen){ Screen= newScreen; }
public float getScreen(){ return Screen;}
调用时:
phone.setScreen(6.4f);
System.out.println("Screen:"+phone.getScreen());
set,get方法对封装数据进行操作
例如:private float Screen
public void setScreen(float newScreen){ Screen= newScreen; }
public float getScreen(){ return Screen;}
调用时:
phone.setScreen(6.4f);
System.out.println("Screen:"+phone.getScreen());
热门评论