Object的clone方法修饰符是protected,可以在同一个包或者子类中访问,但是下面的代码却编译不通过,参考https://blog.csdn.net/ciawow/article/details/8262609
public class Obj {
public static void main(String[] args) {
Object o = new Object();
System.out.println(o.toString());
System.out.println(o.clone().toString());//error,fail to compile
}
}
网友评论