In Java, why do people prepend fields with `this`?

前端 未结 16 2197
广开言路
广开言路 2020-12-20 11:18

When referencing class variables, why do people prepend it with this? I\'m not talking about the case when this is used to disambiguate from method

16条回答
  •  心在旅途
    2020-12-20 11:31

    A slight aside, but it may be worth noting that the "Clean Up" tool in Eclipse can be set to automatically add/remove this. to member accesses according to preference.

    "Java / Code Style / Clean Up" in the preferences dialogue.

提交回复
热议问题