Mega Code Archive

 
Categories / Java Tutorial / Class Definition
 

Public Object clone() throws CloneNotSupportedException

public class Main {   public static void main(String[] args) throws CloneNotSupportedException {     CloneDemo2 cd2 = new CloneDemo2();     System.out.println(cd2.salary);     AnotherClass ac = new AnotherClass();     System.out.println(ac.gradeLetter);     AnotherClass y = (AnotherClass) ac.clone();     System.out.println(y.gradeLetter);   } } class CloneDemo2 implements Cloneable {   double salary = 50000.0; } class AnotherClass implements Cloneable {   char gradeLetter = 'C';   public Object clone() throws CloneNotSupportedException {     return super.clone();   } }