码迷,mamicode.com
首页 > 其他好文 > 详细

this关键字的使用!

时间:2014-10-01 00:37:10      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   使用   ar   java   sp   2014   art   

class Student{
  String name;
  int age;
  
  Student(String name,int age){
    this.name=name;
    this.age=age;	
  }
  
  Student playGame(){
  	  this.age++;
    	return this;
  }
  
  void printword(){
    System.out.println("年龄是"+this.age+"的"+this.name+"打了一天的LOL!");	
  }
}

public class Test{
  public static void main(String[] args){
    Student Hai = new Student("Xiaohai",20);
    Hai.playGame().playGame().printword();
  }
}

 

下面是内存的分析图

bubuko.com,布布扣

this关键字的使用!

标签:style   blog   http   使用   ar   java   sp   2014   art   

原文地址:http://www.cnblogs.com/acgpiano/p/4002759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!