class Point implements Cloneable
{
int x;
int y;
Date dt;
Point(int x, int y)
{
this.x=x;
this.y=y;
dt = new Date();
SimpleDateFormat simdate = new SimpleDateFormat("yyyy");
String date = simdate.format(dt);
}
public Object clone()
{
Point o =null;
try
{
o=(Point)super.clone();
o.dt =(Date)super.clone();
}
catch(Exception e)
{
}
return o;
}
public String toString()
{
return "x="+x +"\t"+"y="+y+"\t" +"date" + dt;
}
main()
{
Point pt = new Point(1,2);
System.out.println(pt);
//Point pt1 = (Point)pt.clone();
Point pt1 = pt;
pt1.x=5;
pt1.y=6;
// change(pt1);
System.out.println(pt);
// System.out.println(pt1);
}
}
{
int x;
int y;
Date dt;
Point(int x, int y)
{
this.x=x;
this.y=y;
dt = new Date();
SimpleDateFormat simdate = new SimpleDateFormat("yyyy");
String date = simdate.format(dt);
}
public Object clone()
{
Point o =null;
try
{
o=(Point)super.clone();
o.dt =(Date)super.clone();
}
catch(Exception e)
{
}
return o;
}
public String toString()
{
return "x="+x +"\t"+"y="+y+"\t" +"date" + dt;
}
main()
{
Point pt = new Point(1,2);
System.out.println(pt);
//Point pt1 = (Point)pt.clone();
Point pt1 = pt;
pt1.x=5;
pt1.y=6;
// change(pt1);
System.out.println(pt);
// System.out.println(pt1);
}
}