Working with Java code from Kotlin comes with fewer limitations and drawbacks. Existing Java code and libraries should generally be completely compatible with your Kotlin code, allowing you to start integrating Kotlin while leveraging existing code.
Working with Java from Kotlin
Using existing code
We can easily instantiate and manipulate Java classes from Kotlin. Let's revisit the Programmer class written in Java:
public class Programmer extends Person {
private String preferredLanguage;
public Programmer(String firstName, String lastName,
String preferredLanguage) {
super(firstName, lastName);
this.preferredLanguage = preferredLanguage;
}
public String getPreferredLanguage...