Kotlin intercalls with Java code

Because Kotlin code is still a class on the JVM platform after compilation, the two can intertune with each other to the extent that

  • Grammar changes
  • Kotlin keyword processing
  • Processing of basic data types

Grammar changes

1. Java calls kotlin2. Kotlin anonymous inner class writing

InnerClass {fun say(STR: String) {} -------------Copy the code

3. Kotlin calls the Java class notation

fun testClass(clazz: Class<TestJava>) {
}
-----------
 //kotlin中调用java的class写法 通过 ::class.java
    testClass(TestJava::class.java)
Copy the code

4. Call kotlin class in kotlin

Fun test(clazz: KClass<KotinMain>) {} ------------------ // Kotlin class :: KotinMain:: KotinMainCopy the code

5. Kotlin conflicts with Java on keywords