Kotlin First Program (IDE)
Syntax
fun main(args: Array<String>) {
println("Hello, World!")
}
Example
fun main(args: Array<String>) {
println("Hello, World!")
}
Output
Hello, World!
Explanation
fun
is a keyword in Kotlin used to define a function.main
is the name of the function that is executed when the program starts.args
is the variable name for an array of command-line arguments.Array<String>
is the data type for theargs
variable, which is an array of strings.println
is a function used to print the string "Hello, World!" to the console.
Use
This program is a simple example of how to use Kotlin to print a message to the console.
Important Points
- Every Kotlin program must have a
main
function that serves as the entry point for the program. - The
println
function is used to print messages to the console. - Kotlin is a statically typed language, meaning that variable types are specified at compile time.
Summary
In this Kotlin program, we've used the fun
keyword to define a main
function that prints the message "Hello, World!" to the console. This program serves as a simple introduction to the Kotlin programming language and its syntax.