<p class="p1">In this article, We will learn how to start with Kotlin Programming and will write a small print “Hello World” program.</p>
<h3><span style="color: #000080;"><strong>Steps:</strong></span></h3>
<ol>
<li>IDE (Java Editor) Installation</li>
<li>Writing Hello World Kotlin program.</li>
</ol>
<h3><span style="color: #000080;"><strong>Kotlin Editor</strong></span></h3>
<p class="p1">To write your Kotlin programs, you will need a text editor. There are different IDEs (Integrated Development Environment) available in the market like Eclipse, Android Studio or IntelliJ IDEA, which are particularly useful when managing larger collections of Kotlin files.</p>
<ul class="ul1">
<li class="li1"><span style="color: #0000ff;"><b>Android Studio</b></span> − An open-source and free IDE provided by Google which supports both Java and Kotlin language. It can be downloaded from <strong><span style="color: #008000;"><a style="color: #008000;" href="https://developer.android.com/studio">https://developer.android.com/studio</a></span></strong>.</li>
<li class="li1"><span style="color: #0000ff;"><b>Eclipse</b></span> − Its Java IDE earlier but now it also supports Kotlin and can be downloaded from <strong><span style="color: #008000;"><a style="color: #008000;" href="https://www.eclipse.org/"><span class="s2">https://www.eclipse.org/</span></a></span></strong>.</li>
<li><b>I<span style="color: #0000ff;">ntelliJ IDEA</span></b> − An IDE developed by JetBrains which supports Java, Kotlin, Android, etc and it&#8217;s free and open-source which can be downloaded from <strong><span style="color: #008000;"><a style="color: #008000;" href="https://www.jetbrains.com/idea/">https://www.jetbrains.com/idea/</a></span></strong>.</li>
</ul>
<p>I will prefer to use <span style="color: #008000;"><b>IntelliJ IDEA </b><span style="color: #000000;">Community version</span></span><b>. </b>Now go to the above-mentioned link to download <b><span style="color: #008000;"><span style="color: #000000;">IntelliJ IDEA </span></span></b><span style="color: #008000;"><span style="color: #000000;">and install it</span></span><b><span style="color: #008000;">.</span></b></p>
<h3><span style="color: #000080;"><strong>Creating New Project in IntelliJ IDEA</strong></span></h3>
<p><strong>1 .</strong> After installation the IntelliJ platform looks like this:</p>
<p><img class="alignnone size-full wp-image-1624" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-15.58.54.png" alt="Screenshot 2020-03-06 15.58.54" width="1552" height="968" /></p>
<p><strong>2</strong> . Click on <span style="color: #008000;"><strong>Create new Project</strong></span>.</p>
<p><img class="alignnone size-full wp-image-1625" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-15.59.45.png" alt="Screenshot 2020-03-06 15.59.45" width="1578" height="1088" /></p>
<p><strong>3</strong> . In the <span class="control">New Project</span> wizard, select <strong><span class="control" style="color: #008000;">Kotlin</span></strong> from the list on the left and also select <span style="color: #008000;"><strong>JVM |IDEA</strong></span>. Click <strong><span style="color: #008000;">Next</span></strong>.</p>
<p><img class="alignnone size-full wp-image-1628" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-16.21.55.png" alt="Screenshot 2020-03-06 16.21.55" width="1610" height="898" /></p>
<p><strong>4</strong> . <span style="color: #008000;"><strong>Name</strong></span> the project, change the <strong><span style="color: #008000;">location</span></strong> of the project if you want, provide project <strong><span style="color: #008000;">SDK</span></strong> path and click &#8216;<strong><span style="color: #008000;">Finish</span></strong>&#8216;.</p>
<p><strong>5</strong> . Inside the <span style="color: #008000;"><strong>src</strong></span> folder, to create a new <span style="color: #008000;"><strong>Kotlin</strong></span> file right-click and then select <strong><span style="color: #008000;">New</span></strong> then <span style="color: #008000;"><strong>Kotlin File/Class</strong></span>.</p>
<p><img class="alignnone size-full wp-image-1629" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-16.33.46.png" alt="Screenshot 2020-03-06 16.33.46" width="1270" height="374" /></p>
<p><strong>6</strong>. Now named the class which you want In my case I will name it as <span style="color: #008000;"><strong>HelloWorld</strong></span>.</p>
<p><img class="alignnone wp-image-1630" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-16.36.25-3072816636-1583492840951.png" alt="Screenshot 2020-03-06 16.36.25" width="443" height="232" /></p>
<!-- WP QUADS Content Ad Plugin v. 2.0.98.1 -->
<div class="quads-location quads-ad2" id="quads-ad2" style="float:none;margin:0px;">

</div>

<p><strong>7</strong>. Inside the <strong><span style="color: #008000;">HelloWorld.kt</span></strong> file, I will write the following code to print &#8220;Hello, World!&#8221; to the screen:</p>
<p class="p1"><span style="color: #0000ff;"><b>Kotlin &#8220;Hello, World!&#8221; Program</b></span></p>
<pre>fun main(args: Array<;String>;) {
 println("Hello, World!")
}</pre>
<p class="p1"><strong>8</strong> . Run the program using the <span style="color: #008000;"><strong>Run</strong></span> button.</p>
<p><img class="alignnone wp-image-1614" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-12.21.31.png" alt="Screenshot 2020-03-06 12.21.31" width="575" height="126" /></p>
<p>When you run the program, You can see the output of the program in the Console screen, the output will be:</p>
<p><img class="alignnone size-full wp-image-1621" src="https://c1ctech.com/wp-content/uploads/2020/03/Screenshot-2020-03-06-15.04.48.png" alt="Screenshot 2020-03-06 15.04.48" width="1512" height="410" /></p>
<h3><span style="color: #000080;"><strong>Understanding Code:</strong></span></h3>
<p>Let&#8217;s understand how &#8220;Hello, World!&#8221; program works in Kotlin.</p>
<h4><span style="color: #000080;"><strong>The main Method</strong></span></h4>
<p><strong>1</strong> . <strong><span style="color: #008000;">fun main(args: Array<;String>;){&#8230;} </span></strong></p>
<p>This is the main function, which is mandatory in every Kotlin application. The Kotlin compiler starts executing the code from the main function.</p>
<p>The function takes array of strings as a parameter and returns <span style="color: #008000;"><strong>Unit</strong></span>.</p>
<p><strong><span style="color: #0000ff;">Unit</span></strong> is same as <strong><span style="color: #008000;">void</span></strong> in Java which means that this method doesn&#8217;t return any value.</p>
<p>The main method must have this exact signature in order to be able to run our program.</p>
<pre>fun main(args: Array<;String>;) {
 ...
}</pre>
<p><strong><span style="color: #0000ff;">Note:</span> </strong>In Kotlin, to define a function we have to use <strong><span style="color: #0000ff;">fun</span></strong> keyword which tells the compiler that it&#8217;s a function.</p>
<p><strong>2</strong> . <strong><span style="color: #008000;">println(&#8220;Hello, World!&#8221;)</span></strong></p>
<p>The <span style="color: #0000ff;"><strong>println()</strong></span> function is an upgraded version of <span style="color: #008000;"><strong>print()</strong></span> which prints any argument passed to it and adds a new line to the output.</p>
<p>In this program, it will print <span style="color: #008000;"><strong>Hello, World!</strong></span> and add a new line.</p>
<p><span style="color: #0000ff;"><strong>Note:</strong> <span style="color: #000000;">There is no need to end</span></span><span style="color: #000000;"> code statements with a semicolon( as we do in Java) because Kotlin performs this internally.</span></p>
<p> ;</p>
<h3 class="p3"><span style="color: #000080;"><b>Comparison With Java &#8220;Hello, World!&#8221; program</b></span></h3>
<p>To learn or compare how to write Hello World Program in Java refer this <strong><span style="color: #0000ff;"><a style="color: #0000ff;" href="https://c1ctech.com/getting-started-with-java/">article</a></span></strong>.</p>
<p><strong>1</strong> . Unlike Java, it is not mandatory to create a class in every Kotlin program. It&#8217;s because the Kotlin compiler creates the class for us.</p>
<p>The name of the Kotlin class is (the name of the Kotlin file) + suffix (Kt). For example, corresponding to <span style="color: #0000ff;"><strong>HelloWorld.kt </strong></span>file the generated class name is <strong><span style="color: #008000;">HelloWorldKt</span></strong>.</p>
<p class="p1"><strong>2</strong>. The <strong><span style="color: #008000;">println()</span></strong> function calls <strong><span style="color: #008000;">System.out.println()</span> </strong>internally.</p>
<p class="p1">If you are using IntelliJ IDEA, put your mouse cursor next to <strong><span style="color: #008000;">println</span></strong> and press( Shortcut: <span style="color: #0000ff;"><b>Ctrl + B</b></span> For Mac: <span style="color: #0000ff;"><b>Cmd + B</b></span>), this will open <strong><span style="color: #0000ff;">Console.kt </span></strong>(declaration file).</p>
<p class="p1">In <span style="color: #008000;"><strong>Console.kt</strong></span> file you can see that <span style="color: #008000;"><strong>println()</strong></span> function is internally calling <span style="color: #008000;"><strong>System.out.println()</strong></span>.

