Does Java SE 8 have Pairs or Tuples?

前端 未结 9 872
独厮守ぢ
独厮守ぢ 2020-11-28 18:37

I am playing around with lazy functional operations in Java SE 8, and I want to map an index i to a pair / tuple (i, value[i]), then <

9条回答
  •  旧巷少年郎
    2020-11-28 19:20

    Since Java 9, you can create instances of Map.Entry easier than before:

    Entry pair = Map.entry(1, "a");
    

    Map.entry returns an unmodifiable Entry and forbids nulls.

提交回复
热议问题