As user chrylis suggests, you could use class for this propose. First, create a class Person.class to store the required values: person ID / person name / place name. For simplifying the process, a constructor with 3 parameters is used here to construct the object, but it's not the only choice. By the way, I strongly suggest you to use a unique value for each person.
public Person(String id, String name, String place) {
this.id = id;
this.name = name;
this.place = place;
}
Then create a method to combine the different information stored in the person class.
public String getCombination() {
return String.format("%s-%s-%s", id, name, place);
}
Now you can put the data into the set combinations:
Set<Person> people = new LinkedHashSet<>();
people.add(new Person("1", "John", "NY"));
people.add(new Person("2", "Bill", "CA"));
people.add(new Person("2", "Ron", "CA"));
people.add(new Person("3", "Rick", "MD"));
people.add(new Person("1", "John", "TX"));
people.add(new Person("3", "Rick", "VA"));
Set<String> combinations = new LinkedHashSet<>();
for (Person p : people) {
combinations.add(p.getCombination());
}
Here's the full implementation of class Person.
public class Person {
private String id; // maybe place id ?
private String name;
private String place;
public Person(String id, String name, String place) {
this.id = id;
this.name = name;
this.place = place;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPlace(String place) {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public String getCombination() {
return String.format("%s-%s-%s", id, name, place);
}
}
2-Bill-CAand2-Ron-CA: you have to people with the samepersonID? Bad juju.