I have confusion about using private methods in inheritance, for example:
public class A {
private void say(int number){
System.out.print(\"A:\"+
If you want a subclass to have access to a superclass method that needs to remain private
, then protected
is the keyword you're looking for.
Private
allows only the class containing the member to access that
member. Protected
allows the member to be accessed within the class and
all of it's subclasses.Public
allows anyone to access the member.