我有一个数据的String id
和一个List<Tuple>
。我需要将这些数据存储到HashMap
中,以便Id是键,list是值。我如何在Java中实现这一点?
您可以使用以下格式来完成。
Map<String, List<Tuple>> map = new HashMap<>(); //Define new map
List<Tuple> list = new ArrayList<>();
//build your tuples here;
map.put("id", list); // Put them into map witk key- your id