在Android Studio中运行一个.kt文件 [英] Run a single .kt file in Android Studio
本文介绍了在Android Studio中运行一个.kt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Android Studio中创建了Scratch Kotlin文件.我只想运行此scratch.kt文件并获取输出.
I created a Scratch Kotlin file in Android Studio. I simply want to run this scratch.kt file and get output.
我摆弄了Run Cofigurations,但不明白将要进入Main Class的内容.
I fiddled with Run Cofigurations but cannot understand what will go into Main Class.
推荐答案
如果您在任何kotlin文件中创建一个名为 main
的顶级函数,则会在其旁边显示一个绿色的运行按钮,该按钮允许您将其作为程序运行:
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:
请注意,这在Android Studio和IntelliJ IDEA中均有效.
Note that this works in Android Studio as well as in IntelliJ IDEA.
这篇关于在Android Studio中运行一个.kt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文