Tue. Dec 3rd, 2024

The following is a collection of basic syntax elements with examples.You’ll find detailed descriptions of each topic at the end of each section

Package definition and imports

Package specification should be at the top of the file

package my.demo

import kotlin.text.*

Program entry point

An entry point of a Kotlin application is the main function:

fun main() {
println("Hello world!")
}

Another form of main accepts a variable number of String arguments:

fun main(args: Array<String>) {
println(args.contentToString())
}

Print to the standard output

print("Hello ")
print("world!")

println prints its arguments and adds a line break, so that the next thing you print appears on the next line:

println("Hello world!")
println(42)

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *