Kotlin Tutoial
Basics
Control Flow
Array & String
Functions
Collections
OOPs Concept
Exception Handling
Null Safety
Regex & Ranges
Java Interoperability
Miscellaneous
Android
In Kotlin, the traditional "Hello, World!" program is quite simple. Here's how you can write it:
fun main() { println("Hello, World!") }
To run this:
Make sure you have the Kotlin compiler installed. You can download it from the official Kotlin website or use SDKMAN, a popular tool to manage parallel versions of multiple Software Development Kits.
Save the code above to a file named HelloWorld.kt
.
Compile the Kotlin code with:
kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
java -jar HelloWorld.jar
Upon running, you should see the output:
Hello, World!
Alternatively, if you are using an Integrated Development Environment (IDE) like IntelliJ IDEA with Kotlin support, you can simply create a new Kotlin project or file and then run the program directly from the IDE.