首页 > 编程语言 > 详细

JAVA-this 关键字

时间:2017-08-31 14:04:45      阅读:218      评论:0      收藏:0      [点我收藏+]

this 关键字代表当前对象:

  • this.属性  ---操作当前对象的属性;
  • this.方法  ---调用当前对象的方法;

封装对象的属性时,经常会使用this关键字;

eg:

package imooc;

public class Telephone{

  private float screen;

  private float cpu;

  private float mem;

  public float getScreen(){

    return screen;

  }

  public void setScreen(float screen){

    this.screen=screen;

  }

}

 

JAVA-this 关键字

原文:http://www.cnblogs.com/Doris9301/p/7457679.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!