Skip to content

Example code for blog post about the Kotlin annotation JvmOverloads

License

Notifications You must be signed in to change notification settings

metters/jvmoverloads

Repository files navigation

Kotlin annotation @JvmOverloads

This example illustrates what the annotation @JvmOverloads does. In Java-Kotlin-mixed projects it makes constructors available to calls from Java that have default parameters. To be precise: Since default parameters do not exist in Java, the compiler adds another constructor and sets the value by itself.

The main method in the Main (Java) class contains three constructor calls. One of them is commented out, because the compiler throws an error. The other two illustrate the instantiation of the respective object using the default parameter. For that to work, those other two classes are in Kotlin - one is with the annotation and the other without.

About

Example code for blog post about the Kotlin annotation JvmOverloads

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published