【发布时间】:2020-01-25 03:40:01
【问题描述】:
使用kotlinc-jvm 1.3.61和kotlinx-coroutines-core-1.3.3,以下代码编译失败。
import kotlinx.coroutines.*
fun main() = runBlocking {
launch {}
}
有错误
Error: Main method not found in class SomeExampleKt, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
然而,以下代码编译运行成功。
import kotlinx.coroutines.*
fun main() = runBlocking {
launch {}
print("") // The only addition
}
谁能解释为什么只添加一个print 语句就可以编译?
【问题讨论】: