<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Java towards Kotlin - Medium]]></title>
        <description><![CDATA[Everything in JAVA now in Kotlin - Medium]]></description>
        <link>https://medium.com/java-towards-kotlin?source=rss----9fb606ff756f---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Java towards Kotlin - Medium</title>
            <link>https://medium.com/java-towards-kotlin?source=rss----9fb606ff756f---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:53:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/java-towards-kotlin" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[03 — Loops (part-2)]]></title>
            <link>https://medium.com/java-towards-kotlin/03-loops-part-2-d45446b43beb?source=rss----9fb606ff756f---4</link>
            <guid isPermaLink="false">https://medium.com/p/d45446b43beb</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[kotlin-native]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Muhammad Awais Rashid]]></dc:creator>
            <pubDate>Fri, 23 Oct 2020 18:02:01 GMT</pubDate>
            <atom:updated>2020-10-23T18:02:01.465Z</atom:updated>
            <content:encoded><![CDATA[<h3>03 — Loops (part-2)</h3><p>Now consider an array and you need to print each element of array with its index</p><h3>JAVA</h3><pre>String[] socialMediaNetworks = {&quot;Facebook&quot;,&quot;Youtube&quot;,&quot;Twitter&quot;,&quot;TikTok&quot;, &quot;Snapchat&quot;, &quot;Whatsapp&quot;};<br><br>for (int socialMediaIndex = 0; socialMediaIndex &lt; socialMediaNetworks.length; socialMediaIndex++) {<br><br>    System.<em>out</em>.println(socialMediaIndex+&quot; - &quot;+socialMediaNetworks[socialMediaIndex]);<br>}</pre><h3>KOTLIN</h3><pre>val socialMediaNetworks = <em>arrayOf</em>(&quot;Facebook&quot;, &quot;Youtube&quot;, &quot;Twitter&quot;, &quot;TikTok&quot;, &quot;Snapchat&quot;, &quot;Whatsapp&quot;)<br><br>for((socialMediaIndex, socialMedia) in socialMediaNetworks.<em>withIndex</em>()) {<br>    <em>println</em>(&quot;$socialMediaIndex - $socialMedia&quot;);<br>}</pre><p>Consider Kotlin Code Block (specifically for loop)</p><p><strong><em>withIndex() </em></strong>is producing sequence of objects containing two values <strong><em>index</em></strong> &amp; <strong><em>value</em></strong></p><p>that’s it</p><p>Happy Coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d45446b43beb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-towards-kotlin/03-loops-part-2-d45446b43beb">03 — Loops (part-2)</a> was originally published in <a href="https://medium.com/java-towards-kotlin">Java towards Kotlin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loops]]></title>
            <link>https://medium.com/java-towards-kotlin/loops-6c806d6a60d6?source=rss----9fb606ff756f---4</link>
            <guid isPermaLink="false">https://medium.com/p/6c806d6a60d6</guid>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Muhammad Awais Rashid]]></dc:creator>
            <pubDate>Sun, 04 Oct 2020 15:16:24 GMT</pubDate>
            <atom:updated>2020-10-04T18:49:38.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>03 — Loops (part-1)</h3><p>its a self-described word i.e. repetition</p><p>In Programming we can say</p><p>Repetition of instructions in a sequence; until specific condition</p><p>In JAVA; for loop contains 3 statements</p><ol><li>Initialization (one time)</li><li>Condition (to execute code block)</li><li>Execution (after execution of code block)</li></ol><p><strong>Example 01</strong></p><p><strong><em>Print 1st 9 natural numbers</em></strong></p><p><strong>JAVA</strong></p><pre>for(int i = 1; i&lt; 10; i++ ) {<br>    System.<em>out</em>.println(i);<br>}</pre><p><strong>KOTLIN</strong></p><pre>for (i in 1 <em>until </em>10) {<br>    <em>println</em>(i)<br>}</pre><p>Consider Kotlin Code Block</p><ol><li>Initialization ( <em>i</em> <strong>in</strong> <em>1</em> ); here <strong>i</strong> is immutable i.e. <strong>val i = 1</strong></li><li>Conditional (<em>from 1 until 10</em>); 10 (non-inclusive)</li><li>Execution (<em>i++</em>); not explicitly mentioned</li></ol><p><strong>Example 02</strong></p><p><strong><em>Print 1st 10 natural numbers</em></strong></p><p><strong>JAVA</strong></p><pre>for(int i=1; i&lt;=10; i++) {<br>    System.<em>out</em>.println(i);<br>}</pre><p><strong>KOTLIN</strong></p><pre>for (i in 1..10) {<br>    <em>println</em>(i)<br>}</pre><p>Consider Kotlin Code Block</p><ol><li>Initialization ( <em>i</em> <strong>in</strong> <em>1</em> ); here <strong>i</strong> is immutable i.e. <strong>val i = 1</strong></li><li>Conditional (<em>1</em><strong>..</strong><em>10</em>); from 1-10 (inclusive)</li><li>Execution (<em>i++</em>); not explicitly mentioned</li></ol><p><strong>Example 03</strong></p><p><strong><em>Print 1st 5 positive even numbers (2, 4, 6, 8, 10)</em></strong></p><p><strong>JAVA</strong></p><pre>for(int i=2; i&lt;= 10; i+=2) {<br>    System.<em>out</em>.println(i);<br>}</pre><p><strong>KOTLIN</strong></p><pre>for(i in 2..10 <em>step </em>2) {<br>    <em>println</em>(i)<br>}</pre><p>Consider Kotlin Code Block</p><ol><li>Initialization ( <em>i</em> <strong>in</strong> 2 ); here <strong>i</strong> is immutable i.e. <strong>val i = 2</strong></li><li>Conditional (<em>2</em><strong>..</strong><em>10</em>); from 2-10 (inclusive)</li><li>Execution (<em>step 2</em>); after execution of every code block <strong><em>i</em></strong><em> </em>will increment by <strong><em>2 i.e. (i+=2)</em></strong></li></ol><p><strong><em>Print 1st 5 positive even numbers in reverse order (10, 8, 6, 4, 2)</em></strong></p><p><strong>JAVA</strong></p><pre>for(int i=10; i&gt;= 2; i-=2) {<br>    System.<em>out</em>.println(i);<br>}</pre><p><strong>KOTLIN</strong></p><pre>for(i in 10 <em>downTo </em>2 <em>step </em>2) {<br>    <em>println</em>(i)<br>}</pre><p>Consider Kotlin Code Block</p><ol><li>Initialization ( <em>i</em> <strong>in</strong> 2 ); here <strong>i</strong> is immutable i.e. <strong>val i = 2</strong></li><li>Conditional (<em>downTo 2</em>); from i=10–2 (inclusive)</li><li>Execution (<em>step 2</em>); after execution of every code block <strong><em>i</em></strong><em> </em>will decrement by <strong><em>2 i.e. (i-=2)</em></strong></li></ol><p>that’s it</p><p>happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c806d6a60d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-towards-kotlin/loops-6c806d6a60d6">Loops</a> was originally published in <a href="https://medium.com/java-towards-kotlin">Java towards Kotlin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[non-final vs final [var vs val]]]></title>
            <link>https://medium.com/java-towards-kotlin/non-final-vs-final-var-vs-val-756f98bf6b80?source=rss----9fb606ff756f---4</link>
            <guid isPermaLink="false">https://medium.com/p/756f98bf6b80</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Muhammad Awais Rashid]]></dc:creator>
            <pubDate>Sat, 29 Aug 2020 14:28:30 GMT</pubDate>
            <atom:updated>2020-10-04T13:46:50.209Z</atom:updated>
            <content:encoded><![CDATA[<h3>02 — non-final vs final [var vs val]</h3><p>In programming, variables can be mutable or immutable</p><p><strong>Mutable</strong> means, value of a variable can be changed when required</p><p><strong>Immutable</strong> means, value of a variable can’t be changed so we use a particular keyword <strong>FINAL </strong>in <strong>JAVA</strong></p><p>how can we present these two in <strong>JAVA</strong></p><pre>public int mutable = 3;<br>public final int immutable = 3;</pre><p>Assigning value to a immutable variable is necessary otherwise you will get a <strong>compile-time-error</strong></p><p>In case of mutable you can change value at any time</p><p>How can we achieve this in <strong>Kotlin</strong></p><p><strong>var </strong>is a keyword used for mutable variables</p><p><strong>val </strong>is a keyword used for immutable variables</p><pre>var mutable = 3;<br>val immutable = 3</pre><p>that’s it</p><p>Happy Coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=756f98bf6b80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-towards-kotlin/non-final-vs-final-var-vs-val-756f98bf6b80">non-final vs final [var vs val]</a> was originally published in <a href="https://medium.com/java-towards-kotlin">Java towards Kotlin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[01 — Hello World]]></title>
            <link>https://medium.com/java-towards-kotlin/01-hello-world-e34e4c7a6421?source=rss----9fb606ff756f---4</link>
            <guid isPermaLink="false">https://medium.com/p/e34e4c7a6421</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Muhammad Awais Rashid]]></dc:creator>
            <pubDate>Mon, 18 May 2020 10:31:46 GMT</pubDate>
            <atom:updated>2020-05-18T10:31:46.512Z</atom:updated>
            <content:encoded><![CDATA[<h3>01 — Hello World</h3><p><em>Print Hello World in Kotlin</em></p><p>Kotlin is a cross-platform, statically typed, general-purpose programming language. It is specifically designed to interoperate fully with JAVA</p><p><strong>Small Steps towards Learning</strong></p><p>Firstly we will see how to print “<strong>Hello World</strong>” in JAVA then in Kotlin</p><p><strong>JAVA</strong></p><pre>public class HelloWorld {<br>    public static void main (String[] args) {<br>        System.<em>out</em>.println(&quot;Hello World...&quot;);<br>    }<br>}</pre><p><strong>Kotlin</strong></p><pre>class HelloWorld {<br>    companion  object {<br>        @JvmStatic<br>        fun main(args: Array&lt;String&gt;) {<br>            println(&quot;Hello World...&quot;)<br>        }<br>    }<br>}</pre><p><strong>Any Differences</strong></p><pre>println(&quot;Hello World...&quot;) = System.<em>out</em>.println()</pre><p>Also no need to use semicolons ( <strong>;</strong> )</p><p>That’s it</p><p>Happy Coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e34e4c7a6421" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-towards-kotlin/01-hello-world-e34e4c7a6421">01 — Hello World</a> was originally published in <a href="https://medium.com/java-towards-kotlin">Java towards Kotlin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>