In my Kotlin project, I have some parts of Java code that I want to convert to Kotlin. The menu item that converts the Java file to Kotlin is disabled because it's not a whole file I want to convert.

How can I convert Java code to Kotlin?

推荐答案

没有将Kotlin代码转换为Java的工具.如果要将文件的一部分从Java转换为Kotlin,最简单的方法是从IDE中的Java文件复制代码,并将其粘贴到Kotlin文件中.

Kotlin相关问答推荐

在Kotlin中,有没有一种函数方法将一个列表(N个元素)映射到一个相邻元素之和列表(N—1个元素)?

如果启用了Flyway迁移,则不能具有配置属性';datources.default.架构-生成

jOOQ Kotlin Coroutines - Select all and exists查询

捕捉异常是Kotlin协程中的反模式吗?

如何通过更改现有数据类型来执行Android房间数据库迁移?

Kotlin Poet 的导入不明确

在 Kotlin 中实现并输入 Either

如何在 kotlin 中的数据类中为变量提供多种类型

如何从 Period.between() 返回的字符串中提取信息? (Kotlin )

Kotlin 如何使用其 get 函数在内部检索映射值

Kotlin Path.useLines { } - 如何不获取 IOException("Stream closed")?

将 Integer 转换为 Unit 编译成功

Kotlin 列表扩展功能

如何使用 Kotlin KClass 属性 simpleName 生成空值

jetpack compose 将参数传递给 viewModel

Anko 中的水平线性布局

Kotlin boxed Int 不一样

Android Room - error: Cannot figure out how to save this field into database

launch 仅从 Kotlin 1.3 开始可用,不能在 Kotlin 1.2 中使用

如何在 Kotlin 中按字母顺序对字符串进行排序