main(String[] args) { CustomerKotlin customerKotlin = new CustomerKotlin(1, "Guy", "
[email protected]"); customerKotlin.setEmail(“
[email protected]”); String value = customerKotlin.someField; customerKotlin.changeStatus(Status.Current); //check the default parameter customerKotlin.changeStatus(); //Annotation set name for Java. customerKotlin.Preferential(); try { customerKotlin.loadStatistics("filename"); } catch (IOException e) { e.printStackTrace(); } //Invoke Top Level Function //Like Kotlin created a static class with a static method. //TopLevelFunctionsKt.prefix("some", "value"); UtilityClass.prefix("some", "value"); UtilityClass.getCopyrightYear(); //Talking to the extension function it requires an instance of the class "customerKotlin" CustomerKotlinKt.extensions(customerKotlin, "Test"); } data class CustomerKotlin (var id: Int, var name: String, var email: String){ @JvmField val someField = "Value" override fun toString():String{ return "{\"id\": \"$name\", \"name\": \"$name\"}" } @JvmOverloads fun changeStatus(status: Status = Status.Current){ } @JvmName("Preferential") fun makePrefered(){ } @Throws(IOException::class) fun loadStatistics(filename: String){ if(filename == ""){ throw IOException("Filename can not be empty") } } }