Why explicitly write “private”?

2019-01-25 01:28发布

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

8条回答
We Are One
2楼-- · 2019-01-25 02:28

Explicit declaration used to told you that the variable is deliberately set to private and it needs to be declare as private

查看更多
Rolldiameter
3楼-- · 2019-01-25 02:34

In my opinion it makes the code better readable. I don't have to think about the default access modifier. It's also enforced by StyleCop, a tool I use to ensure a consistent coding style.

查看更多
登录 后发表回答