今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Accessing collection elements with streams
- [Instructor] The Streams API and Lambdas added to Java 8 gave us a concise functional style for writing code. Let me show you through an example. In our application, we have a collection of rooms that I iterate through and check if the room is pet friendly. If it is, I write its name out to the console. This style of code is known as the imperative style. When we use an imperative style, we have to specify exactly how we want the code to behave. So I need to write the code that does the iteration, performs the conditional check and writes the information to the console. When we use a functional style with streams, it's a little bit different. It's more like we tell the code what we want to achieve. Let me show you. So first, think of a stream as a pipeline that our elements flow through but it never stores them like a collection. The elements are always moving forward through the stream. So first, we need a source…
内容
-
-
-
-
-
(已锁定)
Iterating collection elements2 分钟 55 秒
-
(已锁定)
Accessing collection elements with iterators6 分钟 4 秒
-
(已锁定)
Modifying collections while iterating4 分钟 39 秒
-
(已锁定)
Accessing collection elements with streams5 分钟 38 秒
-
Lambda expressions2 分钟 56 秒
-
(已锁定)
Stream operations4 分钟 17 秒
-
(已锁定)
Challenge: Iterating collections5 分钟 23 秒
-
(已锁定)
-
-
-
-
-
-