tihs 关键字

//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");
    }
}

 

posted @ 2015-09-22 17:38  Xiao|Deng  阅读(204)  评论(0编辑  收藏  举报