Kotlin Notes for Professionals

Tác giả : goalkicker.com
  • Lượt đọc : 411
  • Kích thước : 1.05 MB
  • Số trang : 94
  • Đăng lúc : 3 năm trước
  • Số lượt tải : 169
  • Số lượt xem : 1.614
  • Đọc trên điện thoại :
  • Đọc Kotlin Notes for Professionals trên điện thoại
This Kotlin® Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA, see credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified
This is an unofficial free book created for educational purposes and is not affiliated with official Kotlin® group(s) or company(s) nor Stack Overflow. All trademarks and registered trademarks are the property of their respective company owners
The information presented in this book is not guaranteed to be correct nor accurate, use at your own risk
Please send feedback and corrections to [email protected]
---
All Kotlin programs start at the main function. Here is an example of a simple Kotlin "Hello World" program:
Place the above code into a file named Main.kt (this filename is entirely arbitrary)
When targeting the JVM, the function will be compiled as a static method in a class with a name derived from the
filename. In the above example, the main class to run would be my.program.MainKt.
To change the name of the class that contains top-level functions for a particular file, place the following annotation
at the top of the file above the package statement:
@file:JvmName("MyApp")
In this example, the main class to run would now be my.program.MyApp. See also:
Package level functions including @JvmName annotation. Annotation use-site targets
Section 1.2: Hello World using a Companion Object
Similar to using an Object Declaration, you can define the main function of a Kotlin program using a Companion Object of a class.
package my.program
fun main(args: Array) { println("Hello, world!")
}

Thuộc bộ sách