Why explicitly write “private”?

前端 未结 8 1751
孤城傲影
孤城傲影 2020-12-17 08:46

As fields are implicitly private, why there is often explicit declaraion used in the books, articles etc.?

8条回答
  •  感动是毒
    2020-12-17 09:04

    To make your code look nice :).

    You're right it's not necessary, but it's custom to write them anyway. At the very least, every method has a privilege explicitly noted and it makes your code easier to read.

提交回复
热议问题