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

java中的this

java入门第二季--封装--java中的this_第1张图片

自动生成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("无参的构造方法");
    }

}

你可能感兴趣的:(java入门第二季--封装--java中的this)