package com.instanceofjava;

public class Employee implements Cloneable {


int a=0;
           String name="";
       Employee (int a,String name){
 this.a=a;
       this.name=name;
        }

public Employee clone() throws CloneNotSupportedException{
return (Employee ) super.clone();
}
public static void main(String[] args) {
          Employee e=new Employee (2,"Indhu");
            System.out.println(e.name);

                  try {
Employee b=e.clone();
System.out.println(b.name);
                             } catch (CloneNotSupportedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
            }
}

}


Output:
Indhu
Indhu

Instance Of Java

We are here to help you learn! Feel free to leave your comments and suggestions in the comment section. If you have any doubts, use the search box on the right to find answers. Thank you! 😊
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu