首页 > 解决方案 > 在 Android Studio 中运行单个 .kt 文件

问题描述

我在 Android Studio 中创建了一个 Scratch Kotlin 文件。我只是想运行这个 scratch.kt 文件并获得输出。

我摆弄了运行配置,但无法理解主类将进入什么。

在此处输入图像描述

标签: android-studiokotlin

解决方案


If you create a top-level function called main in any kotlin file, a green run button will appear next to it that allows you to run it as a program:
enter image description here

Note that this works in Android Studio as well as in IntelliJ IDEA.


推荐阅读