class
test {
public static void main(
String[] args) {
Object ob = new Object();
boolean b;
Object ob2=null;
ob2 = ob.clone();
b = ob.equals(ob2);
System.out.println("Is ob equal to the clone ob2? - "+b);
}
}
The code above wont compile saying
"Can't access protected method clone in class java.lang.Object. java.lang.Object is not a subclass of the current class. ob2 = ob.clone();"
Ok so I tried to extend Object in the header of class, but still gave same error.
Why isnt this working?? Is it the access privilege that is the issue here?? The only way to compile this for me was make it explicit to the test class object but... still i dont get why above wont compile..
Also, isnt this the same thing?
class test{} and class test extends Object{}?? since every class is child of Object??
I thank you in advance.
=)