equals() perfect 하게 사용하기
List의 contains 메소드를 사용할 일이 있어서 equals() 메소드에 대하여 찾다가 다음과 같은 나이스 사용 예제를 찾게 되었다. 책에다 있는 내용이니궁금한점은 책을 찾다보도록 하자.
public boolean equals(Object otherObject){
if (this == otherObject )
return true;
if (otherObject == null)
return false;
if (getClass() != otherObject.getClass())
return false;
CareCustomer careCustomer = (CareCustomer) otherObject;
return (careCustomerId == careCustomer.careCustomerId
&& customerId == careCustomer.customerId);
}
public boolean equals(Object otherObject){
if (this == otherObject )
return true;
if (otherObject == null)
return false;
if (getClass() != otherObject.getClass())
return false;
CareCustomer careCustomer = (CareCustomer) otherObject;
return (careCustomerId == careCustomer.careCustomerId
&& customerId == careCustomer.customerId);
}
0 TrackBacks
Listed below are links to blogs that reference this entry: equals() perfect 하게 사용하기 .
TrackBack URL for this entry: http://dongchimi.unfix.net/mt/mt-tb.cgi/35
Leave a comment