Initialization List with values in one row in Java

Java 9: List.of(“a”, “b”, “c”); Set.of(“a”, “b”, “c”); Java 8: Stream.of(“a”, “b”, “c”).collect(Collectors.toList()); Stream.of(“a”, “b”, “c”).collect(Collectors.toCollection(ArrayList::new)); Older: Collections.singletonList(); Arrays.asList(); new ArrayList() {{ add(“a”); add(“b”); add(“c”); }};

Java 9: New Features

Java 9 REPL (JShell) Factory Methods for Immutable List, Set, Map and Map.Entry Private methods in Interfaces Java 9 Module System Process API Improvements Try With Resources Improvement CompletableFuture API Improvements Reactive Streams Diamond Operator for Anonymous Inner Class Optional Class Improvements Stream API Improvements Enhanced @Deprecated annotation HTTP 2 Client Мulti-Resolution Image API Miscellaneous […]