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

后端 未结 9 1995
北海茫月
北海茫月 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:36

    In the second example one of the arguments is named x. By referencing this.x, you mean the x field/property of the class the method is part of. It could read as: Point.x = argument x

    this is being used to differentiate the two, making the meaning of the code clear.

提交回复
热议问题