回覆列表
  • 1 # IT極客老兵

    Map<String, Integer> maps = new HashMap<>();

    maps.put("clothes", 120);

    maps.put("grocery", 150);

    maps.put("transportation", 100);

    maps.put("utility", 130);

    maps.put("rent", 1150);

    maps.put("miscellneous", 90);

    System.out.println("map before sorting: " + maps);

    List<Entry<String, Integer>> listMap = maps.entrySet().stream()

    .sorted(Map.Entry.<String, Integer>comparingByValue()).collect(Collectors.toList());

    System.out.println("map after sorting by keys: " + listMap);

  • 中秋節和大豐收的關聯?
  • 子女該不該聽父母的話?