少年阿宾

那些青春的岁月

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

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();
 }
}

posted on 2012-10-24 13:27 abin 阅读(420) 评论(0)  编辑  收藏 所属分类: JavaBasic

只有注册用户登录后才能发表评论。


网站导航: