Programming Tutorials

Comment on Tutorial - clone() and the Cloneable Interface in Java By Henry



Comment Added by : siva kiran

Comment Added at : 2011-01-20 11:40:23

Comment on Tutorial : clone() and the Cloneable Interface in Java By Henry
Question: if clone is a protected method then why the sub class has to implement Cloneable interface type to use its super class method?
Answer: clone is a dangerous method. So by implementing Cloneable interface you are telling JVM that "There is a good reason to clone my class, so please allow me"


View Tutorial