Hi:
Could anyone pls explain why I'm getting the following error.
My classpath is set to : .;G:\CorejavaBook
Then I created a package under G:\Corejavabook\Corejava --->
package corejava;
public class myclass
{
public myclass()
{
System.out.println("New Object of myclass:" );
}
protected void bite()
{
System.out.println(" In bite");
}
}
When I write the following Class to access the Protected func--->
import corejava.*;
public class cake extends myclass{
public cake()
{
System.out.println("cake constructor");
}
public static void main(
String[] args)
{
myclass x = new myclass();
x.bite();
}
}
I get a error "Can't access protected method bite".I'm new to
Java, could you pls explain why can't I access the protected method. From what is in the book, protected is accessible in subclass in other packages.
Thanks in advance.
newtojava