This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi i'm using the clone method, it's giving me an error while i copile it's saying that clone have a private access! how can i fix that is there another way to clone an abject, (it's like a hashMap) thanks
Originally posted by omar bili: ok, got it thanks, but the thing is that my main class does not implement the clone method, so i cant use the super.clone();
maybe ill have to create my own clone method from nothing, and copy all the variables thanks for the help Omar
In order to support clone(), you ALWAYS have to create your own clone method. However, you only need to copy the variables manually if you need to perform a "deep clone". If you just need a shallow clone, then you should call super.clone() as shown. Note that this typically calls the default clone() method from Object.