Map<String, List<NumberAssignVo>> proMap = new HashMap<>(); for (NumberAssignVo numberAssignVo : numberAssignVos) { List<NumberAssignVo> tempList = proMap.get(numberAssignVo.getProviderName()); if (tempList == null) { tempList = new ArrayList<>(); tempList.add(numberAssignVo); proMap.put(numberAssignVo.getProviderName(), tempList); } else { tempList.add(numberAssignVo); } } Map<String, Map<String, List<NumberAssignVo>>> resultMap = new HashMap<>(); for(String providerName : proMap.keySet()){ List<NumberAssignVo> tempList1 = proMap.get(providerName); Map<String, List<NumberAssignVo>> countryMap = new HashMap<>(); for (NumberAssignVo numberAssignVo1 : tempList1) { List<NumberAssignVo> tempList2 = countryMap.get(numberAssignVo1.getCountryEnName()); if (tempList2 == null) { tempList2 = new ArrayList<>(); tempList2.add(numberAssignVo1); countryMap.put(numberAssignVo1.getCountryEnName(), tempList2); } else { tempList2.add(numberAssignVo1); } } resultMap.put(providerName,countryMap); }