我想要 一个 name对应一个list
时间: 2024-03-20 07:41:02 浏览: 71
好的,那么你可以将代码改为如下所示:
```
Map<Object, Object> datamap = new HashMap<>();
for (int j = 0; j < typeList.size(); j++) {
String typeName = typeList.get(j).getDsmType();
List<Object> dataList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
Map<Object, Object> dataMap = new HashMap<>();
dataMap.put("driverName", list.get(i).getDriverName());
dataMap.put("fatigue", list.get(i).getFatigue());
dataMap.put("callPhone", list.get(i).getCallPhone());
dataMap.put("smoke", list.get(i).getSmoke());
dataMap.put("overSpeed", list.get(i).getOverSpeed());
dataMap.put("overWeight", list.get(i).getOverWeight());
dataMap.put("overHeight", list.get(i).getOverHeight());
dataMap.put("noSeatBelt", list.get(i).getNoSeatBelt());
dataList.add(dataMap);
}
datamap.put(typeName, dataList);
}
```
这样,你就可以通过 `datamap.get(typeName)` 来获取与该类型名对应的数据列表了。
阅读全文