Почему в строке я не могу вызвать метод Object o = new Object().clone(); ,метод clone() есть в классе Object но при вызове он не находится .
public class Solution {
Object o = new Object().clone(); // -ОШИБКА
public static class A implements Cloneable {
private int i;
private int j;2
public A(int i, int j) {
this.i = i;
this.j = j;
}
@Override
protected Object clone() throws CloneNotSupportedException {
return new Object().clone(); // ОШИбКА
}
public int getI() {
return i;
}
public int getJ() {
return j;
}
}