General java override clone method -
lets have super class clone able interface , deep overridden clone method.
i have subclass b.
b temp = new b(); b temp_clone = (b) temp.clone(); the method temp.clone() returns reference cloned super class a, right?
from understanding, can't put reference super class in sub class object, right?
so how code written here possible? because of casting?
thanks.
the class object's clone() method creates , returns copy of object, same class , fields having same values. however, object.clone() throws clonenotsupportedexception unless object instance of class implements marker interface cloneable.
Comments
Post a Comment