-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6465186
commit 24c4823
Showing
2 changed files
with
52 additions
and
0 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,24 @@ | ||
package com.betterzhang.learnkotlin.java; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* Author : Andrew Zhang | ||
* Email : betterzhang.dev@gmail.com | ||
* Time : 2017/06/28 下午 1:23 | ||
* Desc : 匿名函数 ( Lambda 表达式 ) | ||
*/ | ||
public class Lambda { | ||
|
||
public static void main(String[] args) { | ||
|
||
new Thread(() -> System.out.println("Hello Java")).start(); | ||
|
||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
System.out.println("Hello Java"); | ||
} | ||
}).start(); | ||
} | ||
|
||
} |
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,28 @@ | ||
package com.betterzhang.learnkotlin.kotlin | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* Author : Andrew Zhang | ||
* Email : betterzhang.dev@gmail.com | ||
* Time : 2017/06/28 下午 1:27 | ||
* Desc : description | ||
*/ | ||
|
||
fun main(args: Array<String>) { | ||
|
||
Thread(Runnable { | ||
println("Hello Kotlin") | ||
}).start() | ||
|
||
// Kotlin Lambda 表达式语法 | ||
val sum = {x: Int, y: Int -> x + y} | ||
val sum1: (Int, Int) -> Int = {x, y -> x + y} | ||
val sum2 = fun(x: Int, y: Int): Int { | ||
return x + y | ||
} | ||
|
||
println(sum(2, 8)) | ||
println(sum1(3, 9)) | ||
println(sum2(5, 12)) | ||
|
||
} |