Java 8 List转Map

 

参考:http://www.tuicool.com/articles/umiMjmE

 

Map<Integer, Album> albumsByCatalogNumber =
    albums.stream()
          .collect(Collectors.toMap(a -> a.getCatalogNumber(), a -> a));