下面的程序,为什么不能通过编译?
class Base
{
public String classname= "Base";
}
class Derived extends Base
{
private String className = "Derived";
}
public class PrivateMatter
{
public static void main(String [] args)
{
System.out.println(new Derived().className);
}
}作者: 郑传庆 时间: 2012-6-13 19:28
class Base {
public String classname = "Base";
}
class Derived extends Base {
public String className = "Derived";//改成公有的
}
public class PrivateMatters {
public static void main(String[] args) {
System.out.println(new Derived().className);//className不能定义为私有的,定义为私用的,外部的类就访问不了
} 作者: 郑冬 时间: 2012-6-13 19:36
郑传庆 发表于 2012-6-13 19:28
class Base {
public String classname = "Base";
}