The practical operation of mutual conversion between kotlin and java

When doing Android development, you need to be familiar with the java language and at the same time understand kotlin, but this is very unfriendly to Xiaobai, but android studio comes with tools that can realize mutual conversion between java and kotlin .

1. Kotlin to Java

<1>. Stay in the android studio on the kt file page to convert the java source file
<2>. Click Tools->Kotlin->Show Kotlin Bytecode in the toolbar
insert image description here
<3>. Click Decompile
insert image description here
<4>. Success
insert image description here

2. java to kotlin

<1>. Stay in the android studio on the java file page where you want to convert the kt source file
<2>. Click Code->Convert Java File to Kotlin File on the toolbar
insert image description here
<3> to complete

Guess you like

Origin blog.csdn.net/weixin_43202123/article/details/125747448