class Customer implements Cloneable{
int id;
String name;
int age;
long phone;
String dno;
String street;
String town;
int pincode;
Customer(int id, String name,int age, long phone, String dno, String street, String town,int pincode)
{
this.id= id;
this.name=name;
this.age=age;
this.phone=phone;
this.dno= dno;
this.street= street;
this.town=town;
this.pincode=pincode;
}
void show(){
System.out.println(id+" "+name+" "+age+" "+phone);
System.out.println("ADDRESS :"+ dno+" "+street+" "+town+" "+pincode);
System.out.println("***********************************");
}
public Object clone() throws CloneNotSupportedException
{
if(this instanceof Cloneable){
Customer cus= new Customer(this.id, this.name,this.age,this.phone,this.dno,this.street,this.town,this.pincode);
return cus;
}
else throw new CloneNotSupportedException(getClass().getName());
}}
public class Test{
public static void main(String args[]) throws CloneNotSupportedException{
Customer cus1=new Customer(10,"sri",10,81438900L,"20/789","Ramalaya street","hyd",521001);
Customer cus2=(Customer)cus1.clone();
System.out.println(cus1==cus2);
cus1.show();
cus2.show();
cus2.name="bhavani";
cus1.show();
cus2.show();
}}