Java Blog

 
 
 
 public class JAVA_080
 {
    public static void main(String[] args)
    {
       try
       {
          PetDog myPet=new PetDog(\"Fang\",\"Chihuahua\");
          PetDog yourPet=(PetDog)myPet.clone( );

          yourPet.setName(\"Gnasher\");
          yourPet.getFlea( ).setName(\"Atlas\");

          System.out.println(\"\\nYour Pet Details :\\n\" + yourPet);
          System.out.println(\"\\nMy Pet Details :\\n\" + myPet);
       }

       catch(CloneNotSupportedException exp)
       {
          System.out.println(exp);
       }
    }
 }

 
 
Didn't find what you were looking for? Find more on Program to show an example of Copying i.e. Clonning Objects