欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java this,

来源: javaer 分享于  点击 14224 次 点评:133

java this,


       java中this关键字的含义和用法

  

   this语句,用于构造函数之间互相调用

   示例:

public class MyThis {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		TestThis th = new TestThis();
		System.out.println(th.str);
	}

}

class TestThis{
	public String str;
	public TestThis(){
		this("hello");
	}
	public TestThis(String str){
		this.str = str;
	}
}


    

相关文章

    暂无相关文章
相关栏目:

用户点评