When testing the Kotlin, we need a main function entry that is the same as the Java language, so be careful how you create it.
Right-click
Select the File type when you create a new item here.
When you click OK, you create a. kt file that basically has nothing but a package xx.
Then enter main return, the final generated main function:
Fun Main (args:array<string>) {
}
After generating the main function, we can create the class directly in the current. kt file, which is a bit different from Java, where the main function of Java is written in class, and Kotlin's main function is written in class and can only be used as a regular method to tune Use. So our normal test should say this:
Fun Main (args:array<string>) {
var demo1 = Demo1 ()
demo1.testfun ("content")
}
class Demo1 {
var name:string = "" Fun
Testfun (name:string) {
this.name = name
println (this.name)
}
}