1. Description
(1) Kotlin provides the language function of extension function. With the help of this function, we can add customized methods to any object.
(2) After compilation, use javap to view the bytecode that generated the SayHelloKt.class file.
2. Example
//SayHello.kt package com.rhythm7 fun Any.sayHello() { println("Hello") }
Collections in Java are mainly divided into four categories:
1 , List list: ordered, repeatable;
2, Queue queue: ordered, repeatable;
3, Set collection: non-repeatable;
4. Map mapping: unordered, unique keys, but not unique values.
The above is the detailed content of How to use kotlin functions in java. For more information, please follow other related articles on the PHP Chinese website!