I have a Map and a List My list a master list of some value object and Map contains keys which are id of the value object
I have a value object
public class Value
{
private int id;
private String value;
//set and gets to follow
}
Map valueMap = new HashMap();
valueMap.put(1001,"Test1")//key is id of the value object
valueMap.put(1002,"Test2")
valueMap.put(1003,"Test3")
List list = new Array list();
list.add(value1)
list.add(value2)
list.add(value3)
list.add(value4)
list.add(value5)
From the list i want to extract a subset of list whose value.id is ==key of map
how can i do and iterate over both?
You should use
and
Then, you can do something like this:
or even