资讯专栏INFORMATION COLUMN

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

hightopo / 1664人阅读

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

}

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/73140.html

相关文章

  • java门第二季--封装--什么是java中的封装

    封装 showImg(https://segmentfault.com/img/bVbnAOR?w=1293&h=679); showImg(https://segmentfault.com/img/bVbnAOU?w=1149&h=722); 代码get,set /javaDemo2/src/com/imooc/Telphone.java package com.imooc; import c...

    wslongchen 评论0 收藏0
  • java门第二季--封装--使用包管理java中的

    使用包管理java中的类 showImg(https://segmentfault.com/img/bVbnA8N?w=1125&h=708); showImg(https://segmentfault.com/img/bVbnA8S?w=1074&h=715); showImg(https://segmentfault.com/img/bVbnBbt?w=1136&h=696); 新建包和类 在...

    xeblog 评论0 收藏0
  • java门第二季--封装--java中的仿问修饰符

    java中的仿问修饰符 showImg(https://segmentfault.com/img/bVbnBi9?w=967&h=672); showImg(https://segmentfault.com/img/bVbnBje?w=1207&h=650); showImg(https://segmentfault.com/img/bVbnBjg?w=1259&h=652); private s...

    andycall 评论0 收藏0
  • java门第二季--继承--Object类

    摘要:类方法代码类执行了重写方法右键类执行了两个对象是相等的两个对象是不相等的重写右键年龄狗可以吃东西类执行了两个对象是相等的两个对象是不相等的 Object类 showImg(https://segmentfault.com/img/bVbnBZ2?w=1234&h=657); toString()方法 showImg(https://segmentfault.com/img/bVbnBZ...

    molyzzx 评论0 收藏0
  • java门第二季--多态--java中的多态

    摘要:中的多态引用的多态父类的引用是可以指向子类对象报错方法多态动物具有吃的能力狗具有吃肉的能力狗具有看门的能力父类的引用是可以指向子类对象报错 java中的多态 showImg(https://segmentfault.com/img/bVbnDYA?w=1138&h=612); showImg(https://segmentfault.com/img/bVbnD6B?w=344&h=17...

    codercao 评论0 收藏0

发表评论

0条评论

hightopo

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<