We use equals() to determine equality.

http://static.appfuse.org/appfuse-data/appfuse-data-common/xref/org/appfuse/model/User.html

Matt

On Mon, Mar 9, 2009 at 6:07 AM, JC Fabian <jcfab...@gmail.com> wrote:
> take a look at how the User class implements the compareTo method(I believe
> it implements the Comparable interface). That is how Sets determine whether
> an object added to it is "meaningfully equivalent" to another object in the
> set or not. Try reading about the Comparable interface to get a more solid
> grasp as to how this works. Hope this helps.
>
> JC
>
> On Mon, Mar 9, 2009 at 6:27 PM, maker su <make...@gmail.com> wrote:
>>
>> Hi there,
>> I create a action with a field :
>> private Set<User> users = new HashSet<User>();
>>
>> I add 2 users with differenet email to the Set<User>:
>>
>>   user = new User();
>>   user.setUsername("Unknown");
>>   user.setEmail("a...@gmail.com");
>>   getUsers().add(user);
>>   user = new User();
>>   user.setUsername("Unknown");
>>   user.setEmail("d...@gmail.com");
>>   getUsers().add(user);
>>
>> but it can only add 1 user which is the first one.
>> It seems only can add user to set when username is different.
>> How to do if I would like them with the same name "unknown"?
>>
>> Please hint.
>> Sorry,it's may not much releated to appfuse user question.
>>
>> Thanks,
>> Maker Su
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to