java this,
分享于 点击 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;
}
}
相关文章
- 暂无相关文章
用户点评