Java 8 Stream vs Collection Storage

前端 未结 5 1628
情深已故
情深已故 2021-02-02 01:38

I have been reading up on Java 8 Streams and the way data is streamed from a data source, rather than have the entire collection to extract data from.

This quote in par

5条回答
  •  灰色年华
    2021-02-02 01:43

    Think of the stream as a nozzle connected to the water tank that is your data structure. The nozzle doesn't have its own storage. Sure, the water (data) the stream provides is coming from a source that has storage, but the stream itself has no storage. Connecting another nozzle (stream) to your tank (data structure) won't require storage for a whole new copy of the data.

提交回复
热议问题