课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Implementing lambdas in Java - Java教程
课程: Java: Advanced Concepts for High-Performance Development
Implementing lambdas in Java
- Now that we've seen how functional interfaces work, let's see how we can replace a lot of the boiler plate code by using landers instead. So, so far I've got two implementations of my greeting interface. One called Hello World Greeting, and one called Good Morning Greeting. So, let's say I want to add a third one that prints out good afternoon. If I did that the same way as the others, I'd need to create a new class called Good Afternoon Greeting. But instead I'm going to do this using a lander. So, I'm going to add a new variable in my method, and it's going to be a type greeting, which is the interface name, and I'm going to call this one Good Afternoon Greeting. Then after the equal sign, I'm going to write something which is called an anonymous function. Basically, I'm going to implement the print message method, but using a special syntax. So the first thing I put after the equal sign is a pair of brackets. If…
内容
-
-
-
-
-
-
Functional Interfaces in Java3 分钟 39 秒
-
(已锁定)
Implementing lambdas in Java2 分钟 31 秒
-
(已锁定)
Using method references in Java3 分钟 20 秒
-
(已锁定)
Understanding streams in Java1 分钟 24 秒
-
(已锁定)
Using streams in Java4 分钟 25 秒
-
(已锁定)
Challenge: Functional programming2 分钟 43 秒
-
(已锁定)
Solution: Functional programming3 分钟 30 秒
-
-
-
-
-