Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 kotlin 的新手,我通过安装intellij IDEA开始学习 Kotlin 语言,现在的问题是当我想.kt通过运行按钮运行第二个文件时,它只显示我运行的第一个.kt文件。
.kt
一直显示 Run HelloWorld.kt,我想跑Addition.kt
HelloWorld.kt
Addition.kt
我无法在 kotlin 中运行新的 crated 类,它只显示我在项目中第一次运行的第一类。
只需使用方法左侧的小 Kotlin 按钮main即可运行此方法。这应该可以解决问题。
main
或者,您可以“编辑”您的运行配置以指向所需的main方法。
您可以使用edit configurations面板 将类设置为运行在 那里您可以创建一个新配置来运行第二个类或编辑默认配置以启动第二个类。
edit configurations
但这对于初学者来说可能是不必要的复杂,并且对于任何项目都很少需要。 您可能应该尝试以下任一方法: