
上QQ阅读APP看书,第一时间看更新
How to do it...
Create a Java class with a method name equal to any Kotlin keyword. I am using is as the method name, so my Java class looks as follows:
public class ASimpleJavaClass {
static void is(){
System.out.print("Nothing fancy here");
}
}
Now try calling that method from Kotlin code. If you are using any code editor with the autocomplete feature, it automatically encloses the method name in backticks (` `):
fun main(args: Array<String>) {
ASimpleJavaClass.`is`()
}
Similar is the case with other keywords in Kotlin that are qualified identifiers in Java.