private vs public vs protected vs package in Java
Java has four access modifier namely private, protected and public. package level access is default access level provided by Java if no access modifier is specified. These access modifiers are used to restrict accessibility of a class, method or variable on which it applies. We will start from private access modifier which is most restrictive access modifier and then go towards public which is least restrictive access modifier, along the way we will see some best practices while using access modifier in Java and some examples of using private and protected keywords.
0 commentaires:
Enregistrer un commentaire