I am having troubles related to protected access modifier.
package pack1;
public class A{
protected void m1(){
System.out.println("Protected method");
}
}
package pack2;
import pack1.A;
class B extends A{
}
class C extends B{
public static void main(String[] args){
B b = new C();
b.m1();// Error: method m1() is protected access modifier in package pack 2
}
}
Why is B class' method not accessible even though its present in same package pack 2 in which B class exit? And protected access modifier is accessable in same package so why this error occured?