Copy and paste the Java code into a Kotlin file, and then let Android Studio automatically convert the code to Kotlin. This can be done by using “ctrl+c” and “ctrl+v”.
Another way – it’s to right-click on a Java file in the project explorer and select “Convert Java File to Kotlin File” from the context menu. This will convert the entire Java file to Kotlin and create a new Kotlin file in the same location as the original Java file.
The final way to also convert your Java code to Kotlin code in Android Studio: open the Java file you want to migrate, go to “Code” in the menu bar, select “Convert Java File to Kotlin File”, choose the desired migration settings and a new Kotlin file will be created in the same package as the original Java file.