Is there a way to simulate the C++ ‘friend’ concept in Java?

The ‘friend’ concept is useful in Java, for example, to separate an API from its implementation. It is common for implementation classes to need access to API class internals but these should not be exposed to API clients. This can be achieved using the ‘Friend Accessor’ pattern as detailed below: The class exposed through the … Read more