Hi friedns,
//Demonstrate the clone method

class  TestClone// implements Cloneable
{
	int a;
	double b;
	TestClone cloneTest(){
	try{return (TestClone)super.clone();}catch(CloneNotSupportedException e){System.out.println("cloning not allowed");return this;}
	}
}
class CloneDemo1
{
	public static void main(String[] args) 
	{
    TestClone x1=new TestClone();
	TestClone x2;
	x1.a=10;
	x1.b=20.98;
	x2=x1;
	//x2=x1.cloneTest();//clone x1
	//System.out.println(x2==x1);
   // System.out.println(x2.equals(x1));
	System.out.println(x1.a+" "+x1.b);
	System.out.println(x2.a+" "+x2.b);
	}
}

output:
10 20.98
10 20.98
even if i use the clone method iam getting the same result, iam not finding the difference can u help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.