teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

list.toArray(Data[]::new)からlist.stream().toArray(Data[]::new)に変更

2021/03/03 23:56

投稿

neko_the_shadow
neko_the_shadow

スコア2395

answer CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```Java
4
4
  public static Map<Integer, Map<Integer, Data[]>> toArrayMap(Map<Integer, Map<Integer, List<Data>>> listMap) {
5
- return transformValues(listMap, map -> transformValues(map, list -> list.toArray(Data[]::new)));
5
+ return transformValues(listMap, map -> transformValues(map, list -> list.stream().toArray(Data[]::new)));
6
6
  }
7
7
 
8
8
  public static <S, T, U> Map<S, U> transformValues(Map<S, T> map, Function<T, U> transformer) {