Kotlin - Its Not Just Hello World

 
 
fun main(args : Arrays<String>){
println("Its not just a Hello world..!!!"); 
} 


     // Yes ... No need to write boiler plate code now..!!!
 
 without class we can write code in kotlin , yes internally
 compiler creates class for us.
 
 compiler generated class name - filename with Kt append - filenamKt
 
 kotlinc filename.kt - complie
 kotlin finlenameKt  - Run

output - 
 
Its not just a Hello world..!!!
 
======================================================= 
 
 
2. If You want to create main method which is static in nature inside 
class then try following snippets 
 
 
 
class Demo {
    companion object {
        @JvmStatic fun main(args: Array<String>) {
            println("Hello Kotlin");
        }
    }
}
 
 
Note - class in kotlin is default public and final 
==================================================================

3.If you want to create main method or any static method -
 there are two ways 
 
1. create companion onject block as above or
2. make object class -



object Demo {
 @JvmStatic fun main(args: Array<String>) {
            println("Hello Kotlin")
    }
}
 

=======================================================================
 

Comments

Popular posts from this blog

Filter In Javafx

Kotlin with StandAlone Complier