In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), public, protected and private, while making class and interface and dealing with inheritance?
Java - the difference between public, protected, package-private and private in Java
access-modifiersjavaprivateprotectedpublic
Related Question
- Java - What’s the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)
- C# - In C#, what is the difference between public, private, protected, and having no access modifier
- Python - Does Python have “private” variables in classes
- Java - Comparing Java enum members: == or equals()
- Java - a JavaBean exactly
- Php - the difference between public, private, and protected
- Java - What’s the difference between @Component, @Repository & @Service annotations in Spring
- Java - How should I have explained the difference between an Interface and an Abstract class
Best Solution
The official tutorial may be of some use to you.
(same pkg)
(diff pkg)
publicprotectedprivate+ : accessible
blank : not accessible