class A
{
public void doKooll() throws CloneNotSupportedException
{
A b=(A)this.clone(); //works fine
}
}
public class CloneTest
{
public static void main(
String[] args)
{
A a= new A();
try
{
a.doKooll();
A b=(A)a.clone(); // ** compile time error here stating clone has protected access in Object.
}
catch(CloneNotSupportedException e)
{
System.out.println("err");
}
// A b=(A)a.clone();
}
}
would anyone please tell that if clone is protected in object then it must be accessible from the same package but here it is not allowing to do so ..... why? btw output of program is "err"