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

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