public?void?setScreen(float?newScreen)?{
screen?=?newScreen;
}
public?void?setScreen(float?screen)?{
this.screen?=?screen;
}這樣沒看出區別來啊 this關鍵字代表當前對象 ? ?用起來有什么好處
3 回答

botao555
TA貢獻48條經驗 獲得超46個贊
public?void?setScreen(float?screen)?{ ????????this.screen?=?screen; }
這段代碼就已經說明了this關鍵字的作用,this.screen代表當前對象的screen成員變量,如果不加this,則screen代表方法的形參或方法內的局部變量,使用this沒有好處壞處之說,只要記住this的作用即可。
添加回答
舉報
0/150
提交
取消