kotlin-functions

fabiomsr:from-java-to-kotlin

FUNCTIONS

Basic Function

Java

1
2
3
public void hello() {
System.out.print("Hello, World!");
}

Kotlin

1
2
3
fun hello() {
println("Hello, World!")
}

Arguments

Java

1
2
3
public void hello(String name){
System.out.print("Hello, " + name + "!");
}

Kotlin

1
2
3
fun hello(name: String) {
println("Hello, $name!")
}
Read more