Skip to content

Commit

Permalink
Java call Kotlin and Kotlin call Java
Browse files Browse the repository at this point in the history
  • Loading branch information
BetterZhang committed Jun 28, 2017
1 parent 76e940f commit 55518c2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/com/betterzhang/learnkotlin/java/JavaCallKotlin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.betterzhang.learnkotlin.java;

import com.betterzhang.learnkotlin.kotlin.MyClass;

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 11:27
* Desc : description
*/
public class JavaCallKotlin {

public static void main(String[] args) {
new MyClass().foo();
}

}
4 changes: 4 additions & 0 deletions src/com/betterzhang/learnkotlin/java/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ public Person(String name, int age) {
this.age = age;
}

@Override
public String toString() {
return "name: " + name + ", age: " + age;
}
}
16 changes: 16 additions & 0 deletions src/com/betterzhang/learnkotlin/kotlin/KotlinCallJava.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.betterzhang.learnkotlin.kotlin

import com.betterzhang.learnkotlin.java.Person

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 11:22
* Desc : description
*/

fun main(args: Array<String>) {
var p = Person("Andrew Zhang", 25)
println(p.toString())
}

0 comments on commit 55518c2

Please sign in to comment.