package-private member is not a private member but a member that has
no access modifier. You can read more about access modifiers at
http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
We can take as a well-known Animal example:
public class Animal {
private String name; //private member
}
public class Dog extends Animal {
public void sayName() {
System.out.println(name); // compile time error - class Dog does
not inherit the private member 'name'
}
}
If you leave 'name' declaration within class Animal without any access
modifier as 'String name' (i.e. make access package-private), then it is
visible to its subclass Dog provided both classes are in the same package.
Additional Data:
"A subclass does not inherit the private members of its parent class.
However, if the super class has
public or protected methods for accessing its private fields, these
can also be used by the subclass" --- TRUE
Private members and variables are accessible only by public or protected methods belongs to same class in the same package or in different package.
you can access private members directly if you run the same class like :
class Demo{
private int value = 10;
private void method(){
System.out.println("abstarction"+value);
}
public static void main(){
new Demo().method();
}
}