Java List with each element having 2 values

java

Solution

how about creating a class that has two elements and create a `List` of that class

class DataHelper{
  String element1;
  String element2;
}

Problem

I have a requirement to have a list, where each element must have 2 values. I want to know what would be the best way to implement it. Should I use `HashSet`, `HashMap` or anything else ? The list should look like this - `<Elem1_val1, Elem1_val2>, <Elem2_val1, Elem2_val2>, <Elem3_val1, Elem3_val2>, .... <Elemn_val1, Elemn_val2>,` The important point here is that val1 and val2 belong to same Element. What would be a good way to implement this? UPDATE: - Can anyone comment about implementing - `List<Map.Entry<ClassA, ClassB>>` - I don't want to have new class, because I just want to store 2 objects which have some co-relation together in one list. Thanks !

Original source