-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* @由于个人水平有限, 难免有些错误, 还请指点: | ||
* @Author: cpu_code | ||
* @Date: 2020-09-15 20:40:44 | ||
* @LastEditTime: 2020-09-15 20:44:59 | ||
* @FilePath: \java\Lambda\lambda9.java | ||
* @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code) | ||
* @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code) | ||
* @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094) | ||
* @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/) | ||
*/ | ||
package Lambda; | ||
|
||
public class lambda9 { | ||
public static void main(String[] args){ | ||
invokeCalc(() -> System.out.println("吃饭")); | ||
} | ||
|
||
private static void invokeCalc(Cook cook){ | ||
cook.makeFood(); | ||
} | ||
} | ||
|
||
/* 使用Lambda必须具有接口,且要求接口中有且仅有一个抽象方法 */ | ||
|
||
interface Cook{ | ||
void makeFood(); | ||
} | ||
|
||
/* | ||
吃饭 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters