Question about protected modifier
From: AIK (asadikhan_at_hotmail.com.error)
Date: 08/18/04
- Previous message: Gibakou: "javax.xml.Parsers location"
- Next in thread: Charlie Bassignani: "Re: Question about protected modifier"
- Reply: Charlie Bassignani: "Re: Question about protected modifier"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 18 Aug 2004 04:41:21 GMT
I have the following two classes:
package birdpack;
public class Bird {
Bird() {}
protected int nFeathers;
}
in bird.java
and
package duckpack;
import birdpack.Bird;
public class Duck3 extends Bird {
Duck3() {}
void foo() {
Bird b = new Bird();
int temp;
temp = b.nFeathers;
}
}
in Duck3.java
When I compile Duck3 I get this error: nFeathers has protected access in
birdpack.Bird. Why is this? I thought the point of a protected modifier is
to allow children of a class to access parent's protected feature even if
the child class is in a different package?
- Previous message: Gibakou: "javax.xml.Parsers location"
- Next in thread: Charlie Bassignani: "Re: Question about protected modifier"
- Reply: Charlie Bassignani: "Re: Question about protected modifier"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]