java入门第二季–封装–java中的this

6次阅读

共计 449 个字符,预计需要花费 2 分钟才能阅读完成。

java 中的 this

自动生成 get 和 set 的方法
右键 -> source -> Genenor getter and setter
package com.imooc;

import com.sun.glass.ui.Screen;

public class Telphone {

private float screen;
private float cpu;
public void sendMessage() {
System.out.println(“sendmessage”);
}

public float getScreen() {
return screen;
}

public void setScreen(float screen) {
this.screen = screen;
this.sendMessage();
}

public float getCpu() {
return cpu;
}

public void setCpu(float cpu) {
this.cpu = cpu;
}

public Telphone() {
System.out.println(“ 无参的构造方法 ”);
}

}

正文完
 0