How to iterate through a hashmap to get every fourth key, value pair?
up vote
0
down vote
favorite
I have a hashmap like this; key value1 key value2 key value3 key value4 key1 value5 key1 value6 key1 value7 key1 value8 key2 value9 ... and so on Now I want to put this in a ListView which contains four rows , and in row1, I want: key value1 key1 value5 key2 value9 key3 value13 and so on till end And in row2, I want: key value2 key1 value6 key2 value10 key3 value14 and so on till end And then the same in rows 3 and 4. There are always only 4 rows. I am having trouble iterating through this. Here is the code I wrote, but it doesn't work. String fourrows = hashMap.get("KEY"); for (int i=0;i<fourrows.length;i++) { HashMap<String, String> listHashMap = new HashMap<>(); listHashMap.put("TA", "ROW VALUE "+fourrows[i]); for...