-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I would suggest something along the lines of the following:
public boolean equals(Object other) {
if (other instance of UserListPK) {
UserListPK comp = (UserListPK)other;
if (comp.getUserID().equals(this.userID) &&
comp.getListID().equals(this.listID)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
Regards,
Stephen.
On Friday 26 January 2001 3:53 am, you wrote:
> The following is my PrimaryKey class and I want to know how should I
> overide the equal() method and whether my code is correct
> can anyone propose me a good site to learn this stuff....
> thanx
> package com.web_tomorrow.user;
>
> // java core API
> import java.io.Serializable;
> public class UserListPK implements java.io.Serializable
> {
> public String userID;
> public String listID;
>
> public UserListPK(){}
>
> public int hashCode()
> {
> StringBuffer strBuff = new StringBuffer( );
> strBuff.append(userID);
> strBuff.append(listID);
>
> String str = strBuff.toString();
> int hashCode = str.hashCode( );
> return hashCode;
> }
>
> public UserListPK(String userID,String listID)
> {
> this.userID = userID;
> this.listID = listID;
> }
>
> public boolean equals()
> {
> what code should I have here..........
> }
>
>
> }
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE6cSUoPmm0AnNwb5MRAreyAJ46eDhKH0MAAeQUyAQEr7CZaQAO9QCdEGDK
4P6Yz+1qj59A41WrH7tGmic=
=pY8k
-----END PGP SIGNATURE-----
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]