I am new to Kotlin development and I have created a separate Kotlin class in Android Studio as below :
class MainClass{
fun main(args: Array<String>) {
println("Hello World");
}
}
But, How can I run this kotlin class, and where the output will be generated.
your main function has to be a top-level function. Try this:
fun main(args: Array<String>) {
println("Hello World");
}
In order to run it, just click on green the icon next to the function name in AS.
Check out this screenshot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With