vendredi 19 octobre 2012

Difference between private, protected, public and package modifier or keyword in Java

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.
Read more »
Share:
Pays/territoire : United States

0 commentaires:

Enregistrer un commentaire