Verify there is a combination of unique string

Sree :
class Details{
 String name;
 String age;
 String email;
 String location;
}

1) If there is List of Details as in List<Details> how to verify for a combination of name and email collectively unique. (i.e) For a single email address there cant be two name entry.

2) How to verify the combination of all fields in the class file is unique.

what would be a perfect data structure to address this ?.

OmG :

You can hash values by a separator like #, and then find that all uniques or not. Hash value for a Details is name + "#" + "email in the first case, and is name + "#" + age + "#" + email + "#" + location in the second case. You can using Hashmap to find duplicates if there is any with the specified key (or hash) for each instance of Details.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=110771&siteId=1