為什么程序中age屬性我用了protected 修飾符 在通過在同包中的其它類不能調用 而默認的卻可以調用 不是默認的安全性要高嗎?
public class Animal {
?proteceed int age ;
?public int big ;
?public void eat(){
System.out.println("動物在吃飯??!");
?}
}
public class Animal {
?proteceed int age ;
?public int big ;
?public void eat(){
System.out.println("動物在吃飯??!");
?}
}
2016-09-09
舉報
2016-09-09
你的protect拼錯了
2016-11-08
如果類本身的修飾是 public 那么
了protected 的成員,能夠被其他類中的子類使用