<?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[Stories by Dilshan Kavinda on Medium]]></title>
        <description><![CDATA[Stories by Dilshan Kavinda on Medium]]></description>
        <link>https://medium.com/@kavindakgd?source=rss-31e9deddf2be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DFBNLHCBIAWJQ7pu</url>
            <title>Stories by Dilshan Kavinda on Medium</title>
            <link>https://medium.com/@kavindakgd?source=rss-31e9deddf2be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:25:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kavindakgd/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why is it always main() method?]]></title>
            <link>https://medium.com/@kavindakgd/why-is-it-always-main-method-bd8e75a1d1b8?source=rss-31e9deddf2be------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd8e75a1d1b8</guid>
            <category><![CDATA[education]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Dilshan Kavinda]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 10:39:30 GMT</pubDate>
            <atom:updated>2023-08-03T17:22:36.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*73UJRYv4cvlnknH1" /></figure><p>When we are coding we always start with this main method. As a beginner you may or may not have worried about this question. Let’s find out!</p><pre>//C<br>#include &lt;stdio.h&gt;<br><br>int main() {<br>    printf(&quot;Hello, World!\n&quot;);<br>    return 0;<br>}</pre><pre>//C++<br>#include &lt;iostream&gt;<br><br>int main() {<br>    std::cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; std::endl;<br>    return 0;<br>}</pre><pre>//Java<br>public class HelloWorld {<br>    public static void main(String[] args) {<br>        System.out.println(&quot;Hello, World!&quot;);<br>    }<br>}</pre><p>These are some simple “Hello world” applications shown above. From simple “Hello World” programs to complex programs we write this main() method.</p><p>Simply, main() can be called as a function. There are two major types of functions in programming.</p><ol><li>Predefined functions (functions that are already present in a system library)</li><li>User-defined functions (functions that are defined by the user)</li></ol><p>So, main() can be described as a combination of these two function types. The signature or the prototype of the main() method is predefined but the body/logic or the implementation of the function is user-defined. That means that the content of the main() method can be whatever the programmer desires.</p><p>The term “main method” is commonly used to refer to the entry point function in most of the programming languages. The term “main” could be any name like “begin”, “start” or something else. Actually, it can be changed from language to language. As an example, programming languages like Python, Perl, and Ruby don’t have traditional main() methods like C or Java. To be clear, in some languages the term “main” is an explicit requirement of the languages (C\C++\Java) whereas in other languages (Python\Ruby) it is not mandatory to include a main() function.</p><p>What is the reason for having this kind of standard entry point function and calling it “main”? Because it increases the ease of understanding for programmers and gives a clear starting point for the execution of the program. (note: C language was created as a successor to the B language. To be backward compatible with the B language, the entry point of C language was also defined as “main”.)</p><p>Using a common name like “main” also makes it easier for developers to switch between projects and programming languages. When they see the “main” function, they know it is the starting point of the program in almost all of the programming languages.</p><p>When we are considering the C/C++ programming development environment, after the loading phase, the operating system looks for the entry point specified in the executable which is the main function. Once the operating system finds the main function, it transfers control to that function, and the CPU then executes the machine code instructions within the main function and any other functions called from it, following the program’s control flow.</p><p>In Java programming development environment, after the loading of the program and the bytecode verification, JVM (Java Virtual Machine) looks for the main() method in the class that serves as the entry point for the program and starts the execution.</p><p>In conclusion, main() method of most programming languages (C\C++\Java) are defined as the entry point of the program, whereas in some other languages (Python\ Ruby) the entry point of the program is named “main” for convenience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd8e75a1d1b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>