Skip to content

Commit

Permalink
接口Java、Kotlin对比实现
Browse files Browse the repository at this point in the history
  • Loading branch information
BetterZhang committed Jun 28, 2017
1 parent 9cbde92 commit 2d4b86f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/com/betterzhang/learnkotlin/java/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.betterzhang.learnkotlin.java;

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 9:54
* Desc : description
*/
public class Book implements Readable {

@Override
public String getContent() {
return "Hello Java";
}

}
14 changes: 14 additions & 0 deletions src/com/betterzhang/learnkotlin/java/Readable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.betterzhang.learnkotlin.java;

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 9:53
* Desc : description
*/
public interface Readable {

String getContent();

}
22 changes: 22 additions & 0 deletions src/com/betterzhang/learnkotlin/kotlin/Book.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.betterzhang.learnkotlin.kotlin

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 9:56
* Desc : description
*/
class Book : Readable {

// override fun getContent(): String {
// return "Hello Kotlin"
// }

override fun getContent(): String = "Hello Kotlin"

override fun getVersion(): Int {
return super.getVersion()
}

}
15 changes: 15 additions & 0 deletions src/com/betterzhang/learnkotlin/kotlin/Readable.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.betterzhang.learnkotlin.kotlin

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 9:55
* Desc : description
*/
interface Readable {

fun getContent(): String
fun getVersion(): Int = 0

}

0 comments on commit 2d4b86f

Please sign in to comment.