Top-level function 'main' not found in package

I get this error even though I have main func in my code…

fun main(a: Int){ if (a < 12){ println ("Good morning, Kotlin" ) } else { println ( "Good night, Kotlin" ) } }
fun greeting(){ main (15 ) }

The main function needs to either take no arguments or an array of strings so the 2 options you have are

fun main() = TODO()
// or
fun main(args: Array<String>) = TODO()

https://kotlinlang.org/docs/tutorials/kotlin-for-py/hello-world.html

This does not mean that you can’t have your main function the way it is, you just need to add one of the 2 options I gave you, e.g.

fun main() = greeting()
fun main(a: Int){ if (a < 12){ println ("Good morning, Kotlin" ) } else { println ( "Good night, Kotlin" ) } }
fun greeting(){ main (15 ) }

Yes @Wasabi375 is correct, although one more important point is to write you main function (Exactly as answered by Wasabi375) but write it outside your class body.

Example :` File Name: App.kt
class App {
fun playground() {
println(“Hello, world!!!”)
}

    }
 fun main() {
        val app = App()
        app.playground()
 }`