Movatterモバイル変換


[0]ホーム

URL:


Skip toContent

New and Enhanced APIs That Take Advantage of Lambda Expressions and Streams in Java SE 8

In Java SE 8, new classes have been added and existing classes have been enhanced to take advantage oflambda expressions and streams, which are described in the lessonAggregate Operations in the Java Tutorials. You can find most of these new and enhanced classes in the following packages:

Many additions to existing classes take advantage of streams. Other additions include methods that accept instances of functional interfaces, which you can invoke with lambda expressions or method references.

New Packages

java.util.function
java.util.stream

Modified Packages

Classes such asBoolean,Integer, and other object wrapper classes for primitive types (seeAutoboxing and Unboxing) are listed here because they have been enhanced with methods that are suitable for targets of method references. For example, you can use the methodInteger.sum as a method reference, as demonstrated in the following example that adds integers contained in a list:

Integer[] intArray = {1, 2, 3, 4, 5, 6, 7, 8 };List<Integer> listOfIntegers =    new ArrayList<>(Arrays.asList(intArray));    System.out.println("Sum of integers: " +        listOfIntegers            .stream()            .reduce(Integer::sum).get());

(Note that you can also add integers contained in a stream with the methodIntStream.sum.)

PackageNew ClassesModified Classes
java.ioUncheckedIOException
BufferedReader

java.lang

not applicableAutoCloseable
ThreadLocal
String
Iterable
CharSequence
Boolean
Integer
Long
Float
Double
java.nio.filenot applicableFiles
java.utilPrimitiveIterator
Spliterator
DoubleSummaryStatistics
IntSummaryStatistics
LongSummaryStatistics
Optional
OptionalDouble
OptionalInt
OptionalLong
Spliterators
SplittableRandom
StringJoiner
Arrays
BitSet
Collection
Comparator
Iterator
List
Map
Map.Entry
LinkedHashMap
Random
TreeMap
java.util.concurrentnot applicableThreadLocalRandom
java.util.jarnot applicableJarFile
java.util.zipnot applicableZipFile
java.util.loggingnot applicableLogger
java.util.regexnot applicablePattern

Copyright © 1993, 2025, Oracleand/or its affiliates. All rights reserved.
Contact Us

[8]ページ先頭

©2009-2025 Movatter.jp