Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class Main { public static HashMap<String, List<Object[]>> getUnitDataMap(List<Object[]> list, int index) { HashMap<String, List<Object[]>> dataMap = new HashMap<String, List<Object[]>>(); for (int i = 0; i < list.size(); i++) { Object obj = list.get(i)[index]; String unit = obj.toString(); if (dataMap.containsKey(unit)) { dataMap.get(unit).add((Object[]) list.get(i)); } else { ArrayList<Object[]> rowdata = new ArrayList<Object[]>(); rowdata.add((Object[]) list.get(i)); dataMap.put(unit, rowdata); } } return dataMap; } }