Can someone explain to me in detail the use of 'this'?

后端 未结 9 2226
北海茫月
北海茫月 2021-01-24 21:51

I don\'t really understand the use of \'this\' in Java. If someone could help me clarify I would really appreciate it.

On this website it says: http://docs.oracle.com/ja

9条回答
  •  忘掉有多难
    2021-01-24 22:31

    If some variable/argument with same name as object's property is defined, it "overlaps" the name of that property and one should use this.var_name.

    So yes, it could be written as this.x = a, but is somewhat redundant.

提交回复
热议问题