DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

Java Stream Api

原文链接

While using Imperative Programming, the developer uses the language constructs to write both what to do and how to do. Whereas while using Declarative Programming, developer has to focus only on defining what to do and the language or the framework takes care of the how to do part. Hence in Declarative Programming, the code is concise and less error-prone.

Unlike other operations we have seen till now, the sorted operation is stateful. It means that the operator will have to see all the elements in the stream before the result of sorting can be provided to further intermediate or terminal operator. Another example of such an operator is distinct

In Stream API, this is achieved using terminal operators. reduce and collect are the generic terminal operators provided for this purpose.