Local variable inference and anonymous class

John Rose john.r.rose at oracle.com
Thu Nov 16 04:10:26 UTC 2017


On Nov 15, 2017, at 5:15 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> 
>    List<String> list = List.of("hello", "world!");
>    Map<Integer, String> map = list.stream()
>      .map(s -> new Object() { int key = s.length(); String value = s; })
>      .collect(Collectors.toMap(t -> t.key, t -> t.value));
>    System.out.println(map);
> 
> so i guess 'leaking' the type of an anonymous class is not an issue.

That's cool; I didn't know Java had anonymous tuples!!!


More information about the amber-spec-observers mailing list