?? thisinconstructor.java
字號:
/**
* Description:
* <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class ThisInConstructor
{
//定義一個名為foo的屬性
public int foo;
public ThisInConstructor()
{
//在Test構造器里定義一個foo變量
int foo = 0;
//使用this代表此構造器剛剛創建的對象
//下面的代碼將會把剛創建對象的foo屬性設置為6。
this.foo = 6;
}
public static void main(String[] args)
{
//所有使用ThisInConstructor創建的對象的foo屬性
//都將被設為6,所以下面代碼將輸出6。
System.out.println(new ThisInConstructor().foo);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -