hello world

发布时间 2023-04-10 11:16:04作者: 泰坦装甲
Hello World
 
 
 
 
 
 
package org.kotlinlang.play         // 1
fun main() {                        // 2
    println("Hello, World!")        // 3
}
 
 
Hello, World!
  1. kotlin码通常定义在包.包定义可选:如你不定义包在源文件,它的内容成默认包.Kotlin code is usually defined in packages. Package specification is optional: If you don't specify a package in a source file, its content goes to the default package.
  2. 切入点对kotlin app是main功.从kotlin1.3,你可声明main不需参数.返回类型不指定,意味功返回不无.An entry point to a Kotlin application is the main function. Since Kotlin 1.3, you can declare main without any parameters. The return type is not specified, which means that the function returns nothing.
  3. println写行尔标准输出.它导入隐含地.也注意分号可选.println writes a line to the standard output. It is imported implicitly. Also note that semicolons are optional.
在kotlin版本早于1.3,main功必有参数尔类型Array<String>.In Kotlin versions earlier than 1.3, the main function must have a parameter of type Array<String>.