+ 8
Private class in another class??
In Java, How can we use a class having private access in any other class which have public access.
3 Respuestas
+ 3
When an attribute or method is considered private, it means that that attribute or method is only recognized by the class itself and can't be used outside of it. You can write a new class within the Java file that contains these methods for that class to be able to use them. If the classes that need the methods happen to be in the same package as the class that contains attributes and methods that you need them to use, change the access-modifier to protected. This allows the classes in that package can use it. I apologize if this wasn't really able to help you as your question was stated vaguely and this is my answer to the best of my ability.
+ 3
I made a simple example:
https://code.sololearn.com/cksr4dY4claI/?ref=app
+ 3
More about inner classes: https://www.tutorialspoint.com/java/java_innerclasses.htm