package net.abin.lee.basic;
public class Can implements Cloneable{
private int id;
private String address;
public Can() {
}
public Can(int id, String address) {
super();
this.id = id;
this.address = address;
}
public Object clone()throws CloneNotSupportedException{
return super.clone();
}
public int hashCode(){
final int prime=31;
int result=1;
result=prime*result+id;
result=prime*result+((address==null?0:address.hashCode()));
return result;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
package net.abin.lee.basic;
import junit.framework.TestCase;
public class UserTest extends TestCase{
public void test1() throws CloneNotSupportedException{
User user1=new User("12","abin",3);
User user2=user1;
User user3=(User)user1.clone();
System.out.println("user1=user2 :"+(user1==user2));
System.out.println("user1equalsuser2 :"+(user1.equals(user2)));
System.out.println("user1=user3 :"+(user1==user3));
System.out.println("user1equalsuser3 :"+(user1.equals(user3)));
}
@Override
protected void runTest() throws Throwable {
System.out.println("55");
super.runTest();
}
}