I'm trying to loop through a HashMap with a String as key and an Object of my Class as value. I want rek1 to have key "A" and rek2 key "B".
Here's my code:
private Map<String, List<X2Y2>> areaMap = new HashMap<String, List<X2Y2>>();
ArrayList<X2Y2> arrList = new ArrayList<X2Y2>();
X2Y2 rek1 = new X2Y2(1.0,1.0, 2.0, 2.0);
X2Y2 rek2 = new X2Y2(3.0,3.0, 4.0, 4.0);
arrList.add(rek1);
arrList.add(rek2);
areaMap.put("A", arrList);
for (Object key : areaMap.keySet()) {
String lKey = (String) key;
List<X2Y2> list = areaMap.get(key);
Log.i("Worku?", list.toString());
}
class X2Y2(var x1: Double, var y1: Double, var x2: Double, var y2: Double) {}
The thing is that I can only get the key value, not the list with my X2Y2. Anyone got any tip that can help me get my X2Y2 values ?