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

tihs 关键字

时间:2015-09-22 18:55:04      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

//this关键词

/*调用类中的属性
调用类中的方法或构造方法
调用当前对象,调用自己的方法,可以省略。
*/
//http://blog.sina.com.cn/s/blog_71f6c1980100wtj4.html



//this指当前对象自己

public class Google{
    String s="hello";
    public Google(String s){
        System.out.println("1--->s:"+s);//指代全局
        System.out.println("2--->this.s:"+this.s);//指向类的属性/方法
        //this.s=s;
        //System.out.println("3--->this.s:"+this.s);
    }
    public static void main(String args[]){
        new Google("hello world");
    }
}

 

tihs 关键字

标签:

原文地址:http://www.cnblogs.com/dengyg200891/p/4829646.html

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