Why friend directive is missing in Java?

后端 未结 8 1428
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 14:23

I was wondering why Java has been designed without the frienddirective that is available in C++ to allow finer control over which methods and instance variables

8条回答
  •  时光取名叫无心
    2020-12-03 14:42

    In general i think it was because of the added cognitive complexity and low number of cases in which it creates an improvement.

    I would say that the extremely huge number of lines of java in production at this moment can attest that the friend keyword is not really a big loss :).

    Please see @dwb's answer for some more specific reasons.

提交回复
热议问题