- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 256字
- 2021-07-02 18:48:32
Java to Kotlin converter (J2K)
Migration of existing Java projects is also quite easy, because we can use Java and Kotlin side by side in the same project. There are also ways to convert existing Java code into Kotlin code by using the Java to Kotlin converter (J2K).
The first way is to convert whole Java files into Kotlin files using the convert Java File to Kotlin command (the keyboard shortcut in Windows is Alt + Shift + Ctrl + K and in macOS is option + shift + command + K), and this works very well. The second way is to paste Java code into an existing Kotlin file and the code will also be converted (a dialog window will appear with a conversion proposition). This may be very helpful when learning Kotlin.
If we don't know how to write a particular piece of code in Kotlin, we can write it in Java, then simply copy to the clipboard and paste it into the Kotlin file. Converted code will not be the most idiomatic version of Kotlin, but it will work. The IDE will display various intentions to convert the code even more and improve its quality. Before conversion, we need to make sure that the Java code is valid, because conversion tools are very sensitive and the process will fail even if a single semicolon is missing. The J2K converter combined with Java interoperability allows Kotlin be introduced gradually into the existing project (for example, to convert a single class at a time).
- 演進式架構(原書第2版)
- Building a RESTful Web Service with Spring
- 軟件測試項目實戰之性能測試篇
- Mastering matplotlib
- 精通Python自然語言處理
- Android程序設計基礎
- 區塊鏈底層設計Java實戰
- RabbitMQ Essentials
- HTML 5與CSS 3權威指南(第3版·上冊)
- Everyday Data Structures
- Learning VMware vSphere
- 青少年學Python(第2冊)
- SQL Server 2012 數據庫應用教程(第3版)
- Laravel Design Patterns and Best Practices
- 啊哈C語言!:邏輯的挑戰(修訂版)