Streams API Architecture
Description
Stream-related interfaces and classes are in the java.util.stream package.
AutoCloseable interface is from the java.lang package.
All stream interfaces inherit from the BaseStream interface, which inherits from the AutoCloseable interface.
AutoCloseable
|
+--BaseStream
|
+--IntStream
|
+--LongStream
|
+--DoubleStream
|
+--Stream<T>
If the streams use collections as their data source, and collections do not need to be closed.
If a stream is based on a closeable data source such as a file I/O channel, we can create the stream using a try-with-resources statement to get it closed automatically.