我想从Java转换以下代码:
useAnt has been deprecated and is scheduled to be removed in Gradle 3.0. The Ant-Based Scala compiler is deprecated, please see https://docs.gradle.org/current/userguide/scala_plugin.html.
fork has been deprecated and is scheduled to be removed in Gradle 3.0. The fork option for the scala compiler is deprecated, please see https://docs.gradle.org/current/userguide/scala_plugin.html.
到Kotlin:
Object from = ...
Class<T> toClass = ...
T result = toClass.cast(from);
怎么做?
答案 0 :(得分:4)
您可以使用Class<T>
属性
java
实例
这应该有效:toClass.java.cast(from)
答案 1 :(得分:0)
对于任何java to Kotlin转换器,请使用网站上提供的在线转换器。
http://try.kotlinlang.org/#/Examples/Longer%20examples/Maze/Maze.kt