Why explicitly write “private”?

前端 未结 8 1726
孤城傲影
孤城傲影 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:15

    Because default access levels vary across languages, and many people program in more than one language. It's easy to become confused, either as the author or as someone reading the code later, thus explicit is nicer to deal with than implicit.

提交回复
热议问题