October 2019
Intermediate to advanced
434 pages
11h 54m
English
The following snippet illustrates our simple Developer class written in Kotlin:
// simple Kotlin class with 2 properties and associated gettersdata class Developer( val name: String, val favoriteLanguage: String)
In the following, you can see how the Developer class written in Kotlin can be used from a Java method:
public class KotlinFromJava { public static void main(String[] args) { Developer developer = new Developer("Your Name", "Kotlin"); String name = developer.getName(); }}
The new instance of Developer is created like any other Java class, and its properties are available via generated getters even though they weren't defined in the Kotlin code. You'll learn more about how this works ...
Read now
Unlock full access