sth about "this"
2006-04-05 19:52
337 查看
public class Test extends Test2
{
Test() { }
public void testMethod(){
System.out.println("method in Test----son");
}
public static void main(String[] args)
{
Test t=new Test();
t.f();
}
}
class Test2
{
Test2() { }
public void testMethod(){
System.out.println("method in Test2----dad");
}
public void f(){
testMethod();
this.testMethod();
}
}
**********************************************************************************************************
What is the output? This is tricky if you do not know the exact meaning of "this".
*********************************************************************************************************
OUTPUT:
E:/MyDoc/Exercises>java Test
method in Test----son
method in Test----son
.
{
Test() { }
public void testMethod(){
System.out.println("method in Test----son");
}
public static void main(String[] args)
{
Test t=new Test();
t.f();
}
}
class Test2
{
Test2() { }
public void testMethod(){
System.out.println("method in Test2----dad");
}
public void f(){
testMethod();
this.testMethod();
}
}
**********************************************************************************************************
What is the output? This is tricky if you do not know the exact meaning of "this".
*********************************************************************************************************
OUTPUT:
E:/MyDoc/Exercises>java Test
method in Test----son
method in Test----son
.
相关文章推荐
- About Derby "ERROR 42X51: The class '***' does not exist or is inaccessible. This can hap pen if the class is not public."
- onFocus="this.blur()",
- Xcode上传App到Appstore时,报错Error ITMS-90049:"This bundle is invalid.The bundle...."
- This parser does not support specification "null" version "null" 问题的处理 .
- about "apt"
- "This is very preliminary result…
- 出现问题"protected:void __thiscall CTalkCDlg::OnIdok(void)"(?OnIdok@CTalkDlg@@IAEXXZ)?
- FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法
- -canOpenURL: failed for URL: "wechat://" - error: "This app is not allowed to query for scheme wech
- Coursera | Andrew Ng (01-week-1-1.5&1.6)—About this Course & Course Resources
- MOSS2007-404 error>"This webpage is not available"
- 【Android问题】解决创建Android模拟器时提示"No system images installed for this target"的问题
- Qt 出现了 Qt error LNK2019: 无法解析的外部符号 "public: __thiscall 怎么解决
- error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)"
- This application failed to start because it could not find or load the Qt platform plugin "xcb".
- This file probably contains a syntax error."错误
- firefox与ie的在html中放onclick="func()"时的func的this的区别
- outline:none || hidefocus="true" || onfocus="this.blur();"
- 为什么要用this.ViewState["ds"]=ds;
- VS2005智能设备项目的Bug:"The OutputPath property is not set for this project..."