首页 > 其他 > 详细

tihs 关键字

时间:2015-09-22 18:53:18      阅读:265      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!