In the last tutorial, we learned about how to set up the environment for Kotlin and how to start new Kotlin project in Eclipse. In this tutorial, we will learn how to write Hello World program in Kotlin. Before going further it is important to mention that we save Kotlin program files with extension .kt. If you want to save you program file with HelloWorld name you have to save it as HelloWorld.kt. Let’s check out code of our first Kotlin program.
fun main (args: Array<String>){
println(“Hello World”)
}
To run this code you can use play button which is available in the toolbar or click on Run in the menu bar then Run As option. You will get the output of this program in the console.
Hello World code Explanation:
- fun: In our code, you can see we started from fun. fun is a keyword in kotlin to define the function after writing fun we write function name.
- main(): The main function is Kotlin is same as main() in java and c. From where the execution of the program starts. In Kotlin main function take an array of string as a parameter.
- println(): The println() is a function which is used to print a string on the screen. We write a string in println() function in double-quotes.
Parvesh Sandila is a results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
