java和kotlin如何相互转化

javakotlin

Shift + Alt + Cmd + k Mac
Shift + Alt + Ctrl + k Windows

如下图所示:
在这里插入图片描述
这里记录下java一键转kotlin遇到的几个错误:
1.Overload resolution ambiguity. All these functions match
原因:名字冲突。编译器不知道引用哪一个
参考链接1
2.Smart cast to 'Type' is impossible, because 'variable' is a mutable property that could have been changed by this time
参考链接2

Kotlinjava(转换后只供参考,不能直接使用)

kotlin转java 只能看到反编译的源码,博主暂时不太清楚有没有直接转java的,有的话麻烦大佬指教下
Tools>Kotlin>Show Kotlin Bytecode
Decompile
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/i_nclude/article/details/106023352