1.Functional Interface(customized consumer, predicate)
2.default methods
3.static methods
4.Lambdas
5.Method references
6.optional
7.Data and time
8.completable feature
9.metaspace
10.stream api(intermediate stream, terminated stream)
11.collectors class methods
12.comparator(adding default and static methods)
-
Module System
-
Jshell
-
interface changes: added private methods
-
stream API improvements
drop while takeWhile ofNullable iterate
-
Optional class API improvements
ifPresentOrElse or stream
-
collector class API improvements
flat mapping filtering
-
String class API improvements
chars codePoints
- Try-With-Resources Improvement
-
Local-Variable Type Inference
example:
var list = new ArrayList<String>(); // infers ArrayList<String> var stream = list.stream(); // infers Stream<String>
2.toUnmodifiableList example:
List<String> strings = toUnmodifiableList
.stream()
.collect(Collectors.toUnmodifiableList());
3.tounmodifiableSet
Set<String> unmodifiableSet = Stream.of("item1", "item2", "item3")
.collect(Collectors.toUnmodifiableSet());
unmodifiableSet.add("item4");
-
toUnmodifiableMap
Map<Integer, String> unmodifiableMap = Stream.of("item1", "item2", "item3", "it") .collect(Collectors.toUnmodifiableMap( String::length, // Key mapper s -> s, // Value mapper (existing, replacement) -> existing + ", " + replacement // Merger function ));
-
orElseThrow
Optional optional = Optional.ofNullable(getValue()); String value = optional.orElseThrow(() -> new IllegalArgumentException("Value must be present"));