<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Raj Pansuriya</title>
    <description>The latest articles on DEV Community by Raj Pansuriya (@rajpansuriya).</description>
    <link>https://dev.to/rajpansuriya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F571439%2Fc98920f1-cc8c-4389-8204-5102879a164a.png</url>
      <title>DEV Community: Raj Pansuriya</title>
      <link>https://dev.to/rajpansuriya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajpansuriya"/>
    <language>en</language>
    <item>
      <title>Loops in JAVA</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Thu, 18 Nov 2021 11:58:36 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/loops-in-java-ff4</link>
      <guid>https://dev.to/rajpansuriya/loops-in-java-ff4</guid>
      <description>&lt;p&gt;Let's suppose you want to print numbers from 1 to 5 or let's say you want to print &lt;code&gt;Hello World!&lt;/code&gt; 5 times on console. One approach to the problem can be as below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("Hello World!");
System.out.println("Hello World!");
System.out.println("Hello World!");
System.out.println("Hello World!");
System.out.println("Hello World!");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now, what would you do if you have to print &lt;code&gt;Hello World!&lt;/code&gt; a thousand times or a million times. Writing a million lines of code can be a solution but surely not an intelligent one. Not just the print statements, think of any set of instructions or tasks which you want to do repetitively. In cases like these, you can use loops. Loops are a utility to perform a task or set of tasks repetitively.&lt;/p&gt;
&lt;h2&gt;
  
  
  Types of loops
&lt;/h2&gt;

&lt;p&gt;There are three types of loops we'll be looking into&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;for loops&lt;/li&gt;
&lt;li&gt;while loops&lt;/li&gt;
&lt;li&gt;do-while loops&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  For loops
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Syntax&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (initialization; condition; increment/decrement) {
    body
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's understand this by our previous example. Let's prin numbers from 1-5.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(int num=1; num&amp;lt;=5; num++) {
    System.out.println(num);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Initialization:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By writing &lt;code&gt;int num=1&lt;/code&gt; we declare and initialize a variable &lt;code&gt;num&lt;/code&gt; to value 1. Instead of declaring the variable inside the loop, we can also declare it before the loop and then just use it&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num;
for(num=1; num&amp;lt;=5; num++) {
    System.out.println(num);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Condition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the second part, we write a condition that our loop will check on every iteration. &lt;code&gt;num&amp;lt;=5&lt;/code&gt; is the condition we wrote for our problem statement because we want to print the numbers from 1-5. There can be some different ways of writing conditions. The same condition &lt;code&gt;num&amp;lt;=5&lt;/code&gt; can also be written as &lt;code&gt;num&amp;lt;6&lt;/code&gt;. That makes sense right? Let the &lt;code&gt;num&lt;/code&gt; be less than or equal to 5 or let it be less than 6 both are just different ways to accomplish the same result in the end.&lt;/p&gt;

&lt;p&gt;You can also use a variable to specify conditions. For example, if you want to print numbers from 1-&lt;code&gt;n&lt;/code&gt; where &lt;code&gt;n&lt;/code&gt; is an integer entered by the user, you can do something like&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scanner input = new Scanner(System.in);

System.out.print("Please enter a number: ");
int n = input.nextInt();

for (int num=1;num&amp;lt;=n ;num++ ) {
    System.out.println(num);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r0efMjYU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637223010146/y_0pkQUXA7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r0efMjYU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637223010146/y_0pkQUXA7.png" alt="image.png" width="470" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increment/decrement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Increment or decrement of the iteration variable (num) as per the need. In our case we want the variable to increase from 1 up to 5.&lt;/p&gt;

&lt;p&gt;There are several ways you can increment/decrement the iteration variable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;num = num +1&lt;/code&gt;: Increment by 1&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;num++&lt;/code&gt;: Increment by 1&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;num+=1&lt;/code&gt;: Increment by 1&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;num+=a&lt;/code&gt;: Increment by &lt;code&gt;a&lt;/code&gt;       (a is any integer)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;num = num + a&lt;/code&gt;: Increment by &lt;code&gt;a&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And same for decrement&lt;/p&gt;

&lt;p&gt;When we run the loop, the variable &lt;code&gt;num&lt;/code&gt; is initialized to &lt;code&gt;1&lt;/code&gt;. Then the program checks for the condition, is &lt;code&gt;1&amp;lt;=5&lt;/code&gt;? The answer is &lt;code&gt;true&lt;/code&gt;. The body of the loop is executed and then the num is incremented by specified values (in our case incremented by 1), hence now &lt;code&gt;num=2&lt;/code&gt;. Then the program again checks for the condition, is &lt;code&gt;2&amp;lt;=5&lt;/code&gt;? The answer is &lt;code&gt;true&lt;/code&gt; again so again the body is executed. This goes on until the 5 is printed and now the value of &lt;code&gt;num=6&lt;/code&gt; because of increment. Now when the program checks for the condition, it'll get a &lt;code&gt;false&lt;/code&gt; value so the program now gets out of the loop.&lt;/p&gt;
&lt;h3&gt;
  
  
  While loops
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Syntax&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (condition) {
    body
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's try and implement our previous example, but this time with using while loop&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num = 1;
while (num&amp;lt;=5) {
    System.out.println(num);
    num++;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The working of a &lt;code&gt;while&lt;/code&gt; loop is more or less the same as that of a &lt;code&gt;for&lt;/code&gt; loop. We initialize a variable, we write a condition based on that variable, we write a body and then we increment the variable. The condition is checked at every iteration by the program.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tkFQEdgH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637223729464/dsY5jGVSq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tkFQEdgH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637223729464/dsY5jGVSq.png" alt="image.png" width="590" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have understood both the loops, the question arises when to use the while loop and when to use the for loop.&lt;/p&gt;

&lt;p&gt;You can use both of the loops interchangeably as you prefer. The reason that they both exist is&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use the for loop when you know how many times the loop is gonna run&lt;/p&gt;

&lt;p&gt;Use the while loop if you do not know how many times the loop is gonna run.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, if you are given a problem to run the loop until the user inputs the letter &lt;code&gt;x&lt;/code&gt;. It's not possible to achieve this using &lt;code&gt;for-loop&lt;/code&gt; but you can do this using while loop as follows&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scanner input = new Scanner(System.in);
char ch = input.next().trim().charAt(0);
while (ch!='x') {
    System.out.println("Hello");
    ch = input.next().trim().charAt(0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;So now the loop will continue until the user inputs letter &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AtJ4lIn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637224980989/1O5vKylzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AtJ4lIn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637224980989/1O5vKylzu.png" alt="image.png" width="620" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--albW4ZQB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637225064990/VkI7-jVGC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--albW4ZQB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637225064990/VkI7-jVGC.png" alt="image.png" width="749" height="435"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Do While loops
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Syntax&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;do {
    body
} while (condition);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Loosely translated, a &lt;code&gt;do-while&lt;/code&gt; loop can be read as&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;do something (body), while the condition is true.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Implementing our previous example using the &lt;code&gt;do-while&lt;/code&gt; loop&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num=1;
do {
    System.out.println(num);
} while (num&amp;lt;=5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Again, one might ask himself, when do we use a &lt;code&gt;while&lt;/code&gt; loop and when to use a &lt;code&gt;do-while&lt;/code&gt; loop? What's the difference between the two of them?&lt;/p&gt;

&lt;p&gt;If you observe, you might notice the difference between the two loops.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the case of while loops, the condition is checked first, and then the body is executed.&lt;/p&gt;

&lt;p&gt;In case of do-while loops body is executed and then the condition is checked.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From these, we can deduce that &lt;strong&gt;&lt;em&gt;there might be the case where while loop will not run at all, but in all possibilities a do while loop will run at least once&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Look at the following example&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num = 6;
while (num&amp;lt;=5) {
    System.out.println(num);
    num++;
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here the iteration variable is already violating the condition, so the while loop will not run at all.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NHowYOp---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637226157328/1bNymD9hmD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NHowYOp---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637226157328/1bNymD9hmD.png" alt="image.png" width="787" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now see what happens if we run a &lt;code&gt;do-while&lt;/code&gt; loop in the same conditions&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num=6;
do {
    System.out.println(num);
} while (num&amp;lt;=5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PWoL3Coe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637226521759/AXtPQBR3d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PWoL3Coe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637226521759/AXtPQBR3d.png" alt="image.png" width="421" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, though the condition is already violated, the loop still runs one time, it executes the body, and then after checking the condition it gets terminated.&lt;/p&gt;

&lt;p&gt;So in cases where you want your loop to run at least once, you can choose &lt;code&gt;do-while&lt;/code&gt; over &lt;code&gt;while&lt;/code&gt; loop.&lt;/p&gt;

&lt;p&gt;That's all about loops. Kunal has discussed some really important examples regarding Fibonacci numbers, Digit counts, Number reversal which is wholly based on the concepts that we have learned in this article. Do check out his video.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ldYLYRNaucM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Also, consider checking my repo for the code of those examples.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Raj-Pansuriya"&gt;
        Raj-Pansuriya
      &lt;/a&gt; / &lt;a href="https://github.com/Raj-Pansuriya/java-dsa"&gt;
        java-dsa
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Feel free to connect via socials&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/Raj-Pansuriya/"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>Switch Statements in JAVA</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Wed, 17 Nov 2021 16:25:16 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/switch-statements-in-java-45h7</link>
      <guid>https://dev.to/rajpansuriya/switch-statements-in-java-45h7</guid>
      <description>&lt;p&gt;We have already seen how to make decisions based on some conditions in the previous article. In this article, we will look at the switch statement which can be used to replace the &lt;code&gt;if...else&lt;/code&gt; statements in some cases to reduce the complexity and improve the readability of the code.&lt;/p&gt;

&lt;p&gt;Normally, if we have to choose one case among many choices, &lt;code&gt;nested if-else&lt;/code&gt; or &lt;code&gt;else if&lt;/code&gt; is used. But if the number of choices is large, &lt;code&gt;switch..case&lt;/code&gt; is a better option as it makes code neat and easier to understand. In switch statements, we can jump to various cases based on our expression. Let’s see how.&lt;/p&gt;

&lt;p&gt;Consider a case in which we want to print a message based on the name of fruit we get from the user&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (grade == 'A') {
    System.out.println("Excellent !");
} else if (grade == 'B') {
    System.out.println("Outstanding !");
} else if (grade == 'C') {
    System.out.println("Good !");
} else if (grade == 'D') {
    System.out.println("Can do better");
} else if (grade == 'E') {
    System.out.println("Just passed");
} else if (grade == 'F') {
    System.out.println("You failed");
} else {
            System.out.println("Invalid grade");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We can make this program more readable by using a &lt;code&gt;switch..case&lt;/code&gt; instead of &lt;code&gt;else if&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Switch Syntax
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch(expression) {
    case value1:
        statement(s)
        break;

    case value2:
        statement(s)
        break;

    /* you can give any number of cases */

    default:
        statement(s)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In &lt;strong&gt;switch(expression)&lt;/strong&gt;, the value of the &lt;code&gt;expression&lt;/code&gt; is compared with the values of all the &lt;code&gt;cases&lt;/code&gt;. If the value of the expression matches the value of a case, then the &lt;code&gt;statement(s)&lt;/code&gt; corresponding to that case is executed.&lt;/p&gt;

&lt;p&gt;So we can write the above example using switch case as&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Test {

    public static void main(String[] args) {
        char grade = 'B';

        switch (grade) {
            case 'A':
                System.out.println("Excellent !");
                break;
            case 'B':
                System.out.println("Outstanding !");
                break;
            case 'C':
                System.out.println("Good !");
                break;
            case 'D':
                System.out.println("Can do better");
                break;
            case 'E':
                System.out.println("Just passed");
                break;
            case 'F':
                System.out.println("You failed");
                break;
            default:
                System.out.println("Invalid grade");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Understanding break statement
&lt;/h2&gt;

&lt;p&gt;Take a look at the following example&lt;/p&gt;

&lt;p&gt;Let's say we want to print a message based on the fruit value entered by the user.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;

public class Switch{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter a fruit: ");
        String fruit = input.next();

        switch(fruit){
            case "mango":
                System.out.println("King of fruits");
            case "apple":
                System.out.println("A sweet red fruit");
            case "orange":
                System.out.println("Round fruit");
            case "grapes":
                System.out.println("small fruit");

        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HG_yWrQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637157879557/XS7BIlOpC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HG_yWrQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637157879557/XS7BIlOpC.png" alt="image.png" width="685" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PRFtoEpD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637157908143/imxv1dC1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PRFtoEpD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637157908143/imxv1dC1r.png" alt="image.png" width="727" height="289"&gt;&lt;/a&gt;&lt;br&gt;
This is unexpected. When we entered &lt;code&gt;orange&lt;/code&gt; the code should have only printed &lt;code&gt;Round fruit&lt;/code&gt; but it printed all the next along with it.&lt;/p&gt;

&lt;p&gt;By this, we understand the behavior of switch-statement. If we do not give a break statement to our switch cases, the switch not only executes the matched case but &lt;strong&gt;&lt;em&gt;all the following cases until it encounters the next &lt;code&gt;break&lt;/code&gt; statement&lt;/em&gt;&lt;/strong&gt;. That's the reason when we enter &lt;code&gt;mango&lt;/code&gt;, all the statements are printed by our program&lt;/p&gt;

&lt;p&gt;That's the reason we have a break statement after every case so that the program will know that once a case is matched it should &lt;code&gt;break out&lt;/code&gt; of the switch statement. So the correct code is&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;

public class Switch{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("Enter a fruit");
        String fruit = input.next();

        switch(fruit){
            case "mango":
                System.out.println("King of fruits");
                break;
            case "apple":
                System.out.println("A sweet red fruit");
                break;
            case "orange":
                System.out.println("Round fruit");
                break;
            case "grapes":
                System.out.println("small fruit");
                break;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GzWLL223--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637158578715/NNw_QRva9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GzWLL223--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637158578715/NNw_QRva9.png" alt="image.png" width="833" height="285"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Understanding default statement
&lt;/h2&gt;

&lt;p&gt;Let's see what happens if we enter some irrelevant input in the above code&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rlCJkU2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637158846525/fL99DekoF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rlCJkU2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637158846525/fL99DekoF.png" alt="image.png" width="705" height="251"&gt;&lt;/a&gt;&lt;br&gt;
We get no output when we enter any fruit which is not in the given cases or anything gibberish. But the code should give some output because no-output would not make much sense to our user. Its cases like this when default case is used. The default will execute when none of the above cases execute.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;

public class Switch{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter a fruit: ");
        String fruit = input.next();

        switch(fruit){
            case "mango":
                System.out.println("King of fruits");
                break;
            case "apple":
                System.out.println("A sweet red fruit");
                break;
            case "orange":
                System.out.println("Round fruit");
                break;
            case "grapes":
                System.out.println("small fruit");
                break;
            default:
                System.out.println("Please enter a valid fruit name");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WQr82Rrl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637159146498/0T-iUn62g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WQr82Rrl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1637159146498/0T-iUn62g.png" alt="image.png" width="716" height="473"&gt;&lt;/a&gt;&lt;br&gt;
As we can see, the program now prints a statement for invalid inputs.&lt;/p&gt;

&lt;p&gt;You may have a default statement anywhere in the switch case and not at the end, but then you'll have to write a &lt;code&gt;break&lt;/code&gt; statement following the &lt;code&gt;default&lt;/code&gt; case so none of the following cases is executed when the default condition is met.&lt;/p&gt;
&lt;h2&gt;
  
  
  Notes for Switch
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Cases have to be of the same type as expression, must be constant or literal.&lt;/p&gt;

&lt;p&gt;The cases can not be an expression like &lt;code&gt;marks &amp;lt; 50&lt;/code&gt; It has to be either a constant or a literal&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Duplicate cases are not allowed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Break is used to terminate&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If &lt;code&gt;break&lt;/code&gt; is not used, it will continue to execute all the next cases&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default will execute when none of the above cases execute&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the default is not at the end, put a &lt;code&gt;break&lt;/code&gt; after it&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Enhanced switch
&lt;/h2&gt;

&lt;p&gt;Enhancements to switch statements were introduced by Java 12 and then further modified by Java 13.&lt;/p&gt;

&lt;p&gt;Let’s dive into the important features of this improved version of the Switch statement.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Switch with arrows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The statements on the right side of an ⇾ are executed if an exact case matches on the left side.&lt;/p&gt;

&lt;p&gt;for example, let say we take int input for a day of the week form the user and want to print the name of the day&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch (day) {
    case 1 -&amp;gt; {
        // you can add braces like this if you want to have multiline code
        System.out.println("Monday");
    }
    case 2 -&amp;gt; System.out.println("Tuesday");
    case 3 -&amp;gt; System.out.println("Wednesday");
    case 4 -&amp;gt; System.out.println("Thursday");
    case 5 -&amp;gt; System.out.println("Friday");
    case 6 -&amp;gt; System.out.println("Saturday");
    case 7 -&amp;gt; System.out.println("Sunday");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Supports multiple values per case&lt;/p&gt;

&lt;p&gt;With multiple values being specified per case, it simplifies the code structure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our previous example, if we do not want the name of the day; instead we only want whether the day is a weekday or weekend&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch (day) {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
        System.out.println("Weekday");
        break;
    case 6:
    case 7:
        System.out.println("Weekend");
        break;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This code can even be enhanced as follows. The case values need to be separated by commas and the break should follow the case block.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch (day) {
    case 1, 2, 3, 4, 5 -&amp;gt; System.out.println("Weekday");
    case 6, 7 -&amp;gt; System.out.println("Weekend");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There are so many other new features about which you can read in this &lt;a href="https://www.geeksforgeeks.org/enhancements-for-switch-statement-in-java-13/"&gt;article&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Nested switch case
&lt;/h2&gt;

&lt;p&gt;In our last article, we saw nested if statements. Similarly, nested switch cases are basically &lt;code&gt;switch-case&lt;/code&gt; inside a &lt;code&gt;switch-case&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can have a look at an example of nested switch and other code samples we discussed in this article in my git repo.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Raj-Pansuriya"&gt;
        Raj-Pansuriya
      &lt;/a&gt; / &lt;a href="https://github.com/Raj-Pansuriya/java-dsa"&gt;
        java-dsa
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Feel free to connect via socials&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/Raj-Pansuriya/"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>Conditionals in JAVA</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Wed, 17 Nov 2021 16:16:49 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/conditionals-in-java-152i</link>
      <guid>https://dev.to/rajpansuriya/conditionals-in-java-152i</guid>
      <description>&lt;p&gt;What makes programming so much more powerful are conditional statements. This is the ability to test a variable against a value and act in one way if the condition is met by the variable or another way if not. They are also commonly called by programmers &lt;em&gt;if statements&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;conditional statements, conditional expressions, and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.&lt;/p&gt;

&lt;h2&gt;
  
  
  Logical operators used to write conditions
&lt;/h2&gt;

&lt;p&gt;Java supports the usual logical conditions from mathematics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Less than: &lt;code&gt;a &amp;lt; b&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Less than or equal to: &lt;code&gt;a &amp;lt;= b&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Greater than: &lt;code&gt;a &amp;gt; b&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Greater than or equal to: &lt;code&gt;a &amp;gt;= b&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Equal to &lt;code&gt;a == b&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Not Equal to: &lt;code&gt;a != b&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These statements provide us either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; value&lt;br&gt;
Java has the following conditional statements:&lt;/p&gt;
&lt;h2&gt;
  
  
  Different types of conditionals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;if&lt;/code&gt; to specify a block of code to be executed, if a specified condition is true&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (boolean expression true/false) {
// block of code to be executed if the condition is true
}
code...
...
...
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;If the condition is &lt;code&gt;true&lt;/code&gt; then the code inside the code block is executed otherwise it is skipped and the program continues from the instruction after the &lt;code&gt;if-block&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, let say we want to decide on a bonus for various employees based on their salaries and then add the bonus to their salaries to get the final amount to be paid to that employee.&lt;br&gt;
&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt; 20000) {
    salary = salary + 2000
}
System.out.println(salary)

1) salary = 5000
output: 5000

2) salary = 20000
output: 20000

3) salary = 21000
output: 21000 + 2000 = 23000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;else&lt;/code&gt; to specify a block of code to be executed, if the same condition is false&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (boolean expression true/false) {
// block of code to be executed if the condition is true
}
else {
// block of code to be executed if the condition is false
}
code ...
.....
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;If the condition is &lt;code&gt;true&lt;/code&gt; then the code inside the &lt;code&gt;if-block&lt;/code&gt; is executed otherwise the code inside &lt;code&gt;else-block&lt;/code&gt; is executed.&lt;/p&gt;

&lt;p&gt;In our previous example, we might want to add a bonus of Rs.1000 for employees having salaries less than Rs.20000&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt; 20000) {
    salary = salary + 2000
}
else {
    salary = salary + 1000
}
System.out.println(salary)

1) salary=5000
output: 5000 + 1000 = 6000

2) salary=20000
output: 20000 + 1000 =  21000

3) salary=21000
output: 21000+2000=23000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Remember, only one of the two, either &lt;code&gt;if&lt;/code&gt; or &lt;code&gt;else&lt;/code&gt; blocks get executed. The two blocks are never executed simultaneously.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;else if&lt;/code&gt; to specify a new condition to test if the first condition is false&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (condition_1) {
// block of code to be executed if the condition_1 is true
}
else if (condition_2) {
// block of code to be executed if condition_1 is false and condition_2 is true
}
else if (condition_3) {
// block of code to be executed if condition_2 is false and  condition_3 is true
}
else {
// block of code to be executed if all the above conditions are false
}
code...
...
...
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;You might have guessed the working of &lt;code&gt;if-else-if&lt;/code&gt; statements. The program starts from the very first &lt;code&gt;if&lt;/code&gt; statement, if the condition is true, the corresponding block is executed otherwise the program counter jumps onto the next &lt;code&gt;if&lt;/code&gt; statement. At last, if none of the conditions is &lt;code&gt;true&lt;/code&gt; then the last &lt;code&gt;else-block&lt;/code&gt; is executed.&lt;/p&gt;

&lt;p&gt;In our previous example, we might want to add a bonus of Rs.5000 having a salary more than or equal to Rs.40000&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt;= 40000) {
    salary += 5000        // same as salary = salary + 5000
}
else if (salary &amp;gt; 20000) {
    salary += 2000        // same as salary = salary + 2000
}
else {
    salary += 1000        // same as salary = salary + 1000
}
System.out.println(salary)

1) salary = 45000
output: 45000 + 5000 = 50000

2) salary = 40000
output: 40000 + 5000 = 45000

3) salary = 21000
output: 21000 + 2000 = 23000

4) salary = 20000
output: 20000 + 1000 = 21000

5) salary = 10000
output: 10000 + 1000 = 11000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Just like the &lt;code&gt;if-else&lt;/code&gt; code, in the &lt;code&gt;if-else-if&lt;/code&gt; code only one of the code blocks is executed at a time. i.e., in the given example only one of the four (the three &lt;code&gt;if-block&lt;/code&gt; and one &lt;code&gt;else-block&lt;/code&gt;) code blocks will be executed.&lt;/p&gt;
&lt;h3&gt;
  
  
  Nested if-else statements
&lt;/h3&gt;

&lt;p&gt;Sometimes we may want to nest if statements so that we can check for more than one condition.&lt;/p&gt;

&lt;p&gt;The syntax for a nested if...else is as follows −&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(Boolean_expression 1) {
   // Executes when the Boolean expression 1 is true
   if(Boolean_expression 2) {
      // Executes when the Boolean expression 2 is true
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In our previous example, we might want to add a bonus of Rs.3000 to the employees who have worked more than 5 years at our company. We can do that as follows&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt;= 40000) {
    salary += 5000        // same as salary = salary + 5000
    if (working_tenure &amp;gt; 5) {
        salary += 3000
    }
}
else if (salary &amp;gt; 20000) {
    salary += 2000        // same as salary = salary + 2000
    if (working_tenure &amp;gt; 5) {
        salary += 3000
    }
}
else {
    salary += 1000        // same as salary = salary + 1000
    if (working_tenure &amp;gt; 5) {
        salary += 3000
    }
}
System.out.println(salary)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here we have added a nested if condition to all the previous if conditions that check the condition and add up the bonus of Rs.3000 if met true.&lt;/p&gt;

&lt;p&gt;You can nest &lt;code&gt;else if...else&lt;/code&gt; in a similar way as we have nested if statement.&lt;/p&gt;
&lt;h4&gt;
  
  
  Caution
&lt;/h4&gt;

&lt;p&gt;Let's see some common mistakes which people tend to do while writing conditional statements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wrong order while specifying conditions in &lt;code&gt;if-else-if&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt;= 20000) {
    salary += 2000        // same as salary = salary + 2000
}
else if (salary &amp;gt; 40000) {
    salary += 5000        // same as salary = salary + 5000
}
else {
    salary += 1000        // same as salary = salary + 1000
}
System.out.println(salary)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Look at the code above. The code seems perfectly fine at first. Now try running the code with a salary input of Rs. 50000. The output you will get will be &lt;code&gt;50000 + 2000 = 52000&lt;/code&gt;. But this does not make any sense. 50000 is greater than 40000 so the final amount should have been 55000. What is it that gave us the wrong output?&lt;/p&gt;

&lt;p&gt;Remember when we discussed how &lt;code&gt;if-else-if&lt;/code&gt; works, we said that &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The next condition is checked ONLY AND ONLY if the previous condition is wrong. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rs.50000 is greater than 40000 but it is also greater than 20000. That means our first condition is &lt;code&gt;true&lt;/code&gt; so the program won't even bother to check further conditions and will skip them. Hence we get the wrong output. The correct (Logically correct to be precise) code for our problem statement would be&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt;= 40000) {
    salary += 5000        // same as salary = salary + 5000
}
else if (salary &amp;gt; 20000) {
    salary += 2000        // same as salary = salary + 2000
}
else {
    salary += 1000        // same as salary = salary + 1000
}
System.out.println(salary)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Understand that while writing &lt;code&gt;if-else-if&lt;/code&gt; statements &lt;strong&gt;&lt;em&gt;all our conditions have to be in DESCENDING/ASCENDING order&lt;/em&gt;&lt;/strong&gt; so none of the conditions is skipped.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ignoring the boundary cases while writing conditions
While writing conditions we should always consider boundary cases. Boundary cases are extreme values where our condition met &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, in the code cell below,&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt; 20000) {
    salary += 5000        // same as salary = salary + 5000
}
else if (salary &amp;lt; 20000) {
    salary += 2000        // same as salary = salary + 2000
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;boundary case is people having &lt;code&gt;salary = 20000&lt;/code&gt;. While writing this code, we totally forgot to consider people with &lt;code&gt;salary = 20000&lt;/code&gt;. So in the end, people having &lt;code&gt;salary &amp;gt; 20000&lt;/code&gt; will get a bonus of Rs.5000; people having &lt;code&gt;salary &amp;lt; 20000&lt;/code&gt; will get a bonus of Rs.2000 and people having &lt;code&gt;salary = 20000&lt;/code&gt; will get no bonus which is a really stupid thing to do as a manager. So the logically correct code would be&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (salary &amp;gt;= 20000) {
    salary += 5000        // same as salary = salary + 5000
}
else if (salary &amp;lt; 20000) {
    salary += 2000        // same as salary = salary + 2000
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Always try to avoid logical mistakes while writing conditionals.&lt;/p&gt;

&lt;p&gt;That's all for this one. Hope you all have got the gist of conditionals and how to use them. Go through my repo and play with conditional programs.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Raj-Pansuriya"&gt;
        Raj-Pansuriya
      &lt;/a&gt; / &lt;a href="https://github.com/Raj-Pansuriya/java-dsa"&gt;
        java-dsa
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Feel free to connect via socials&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/Raj-Pansuriya/"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Datatypes in JAVA</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Mon, 15 Nov 2021 16:33:10 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/datatypes-in-java-pea</link>
      <guid>https://dev.to/rajpansuriya/datatypes-in-java-pea</guid>
      <description>&lt;h2&gt;
  
  
  Primitive Datatypes
&lt;/h2&gt;

&lt;p&gt;Primitive data types in Java are predefined by the Java language and named as the reserved keywords. A primitive data type does not share a state with other primitive values. Primitives are also the data types that one cannot break any further. For example, &lt;code&gt;Raj&lt;/code&gt; is a data of &lt;code&gt;String&lt;/code&gt; type. We can further break it into individual letters &lt;code&gt;R&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, and &lt;code&gt;j&lt;/code&gt; that are further unbreakable into any standalone datatype. All of the individual letters are said to be of &lt;code&gt;char&lt;/code&gt; datatype. So the &lt;code&gt;String&lt;/code&gt; is a &lt;code&gt;non-primitive datatype&lt;/code&gt; and &lt;code&gt;char&lt;/code&gt; is a primitive datatype.&lt;/p&gt;

&lt;p&gt;Let's look at all the primitive data types supported by Java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:-&lt;/strong&gt; All the statements in Java language are ended by a colon ( &lt;code&gt;;&lt;/code&gt; ) symbol stating that the current statement ends and a new statement begins from that point onwards.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;char:&lt;/strong&gt; Used to store a single character or letter
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char letter = 'r';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;int&lt;/strong&gt;: Used to store integers.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int roll_no = 10;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;long:&lt;/strong&gt; Used to store large integer values
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;long large_integer = 198732099873L;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;float:&lt;/strong&gt; Used to store decimal numbers
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;float marks = 77.5f;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;double:&lt;/strong&gt; Used to store large decimal numbers
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double large_decimal = 8172612.769832;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;boolean:&lt;/strong&gt; The data types that have either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; values. Very useful while writing conditional statements.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool check = true;
bool var = false;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Also notice that the syntax to declare variables is as given in the above example.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;datatype identifier = literal;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;literal:&lt;/strong&gt; These are the syntactical representation of our data. In very simple language these are the actual values of our variables&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;identifier:&lt;/strong&gt; Name of variable, classes, methods, function are all known as an identifier. So when we declare a variable, a variable name is an identifier&lt;/p&gt;

&lt;p&gt;Now one might wonder if we have &lt;code&gt;int&lt;/code&gt;, what's the need of &lt;code&gt;long&lt;/code&gt; datatype. The same goes with &lt;code&gt;float&lt;/code&gt; and &lt;code&gt;double&lt;/code&gt;; this has to do with the size of a datatype. An integer takes 4 bytes of memory so anything bigger than that has to be stored in a &lt;code&gt;long&lt;/code&gt; type data and the same is for float. &lt;/p&gt;
&lt;h4&gt;
  
  
  IMP
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;All the decimal values by default are of type double. So if we want to store them in float type variable, we have to specify that by using an &lt;code&gt;f&lt;/code&gt; at the end of our number.&lt;/li&gt;
&lt;li&gt;All the integer values by default are of type &lt;code&gt;int&lt;/code&gt;. The only reason to use long instead of int is to store larger values. We specify that by using &lt;code&gt;L&lt;/code&gt; at the end of the number.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not worry much about these things now. We will study everything about size when we'll be discussing bitwise operators.&lt;/p&gt;
&lt;h2&gt;
  
  
  Inputs for various data types
&lt;/h2&gt;

&lt;p&gt;As there are different data types, there are different methods given by the &lt;code&gt;Scanner&lt;/code&gt; class to take their inputs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;int&lt;/code&gt; : &lt;code&gt;nextInt()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;float&lt;/code&gt; : &lt;code&gt;nextFloat()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;String&lt;/code&gt; : &lt;code&gt;next()&lt;/code&gt; is used to take &lt;em&gt;one-word&lt;/em&gt; inputs and &lt;code&gt;nextLine()&lt;/code&gt; is used to take input more than a word.
for exmaple if the input given is &lt;code&gt;Hey Raj!!&lt;/code&gt;, only &lt;code&gt;Hey&lt;/code&gt; will be taken if &lt;code&gt;next()&lt;/code&gt; is used and complete input will be taken if &lt;code&gt;nextLine()&lt;/code&gt; is used. Baiscally &lt;code&gt;next()&lt;/code&gt; method ignores anything after first white space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below is a basic program demonstrating inputs we discussed so far.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;

public class Input {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter your full name: ");
        String full_name = input.nextLine();
        System.out.print("Enter your first name: ");
        String name = input.next();
        System.out.print("Enter your division: ");
        String division = input.next();
        System.out.print("Enter your roll no: ");
        int rollno = input.nextInt();
        System.out.print("Enter your maths marks: ");
        float marks = input.nextFloat();

        System.out.print("Name : "+full_name);
        System.out.print("Division : "+division);
        System.out.print("Roll no. : "+rollno);
        System.out.print("Marks : "+marks);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E2593zDk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636986829111/kKheP3fVW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E2593zDk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636986829111/kKheP3fVW.png" alt="image.png" width="877" height="382"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Type Conversion &amp;amp; Casting
&lt;/h2&gt;

&lt;p&gt;If you try to enter an integer or float in a string-type variable you will get an error and the program will fail. The same is true when you enter a float to an int-type variable. On the other hand, if you provide an integer to float-type data, the integer automatically gets converted to float.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gDDaYaID--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636986969600/2BCg8TD4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gDDaYaID--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636986969600/2BCg8TD4w.png" alt="image.png" width="518" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, in the above picture though the input given is &lt;code&gt;89&lt;/code&gt; it gets converted to &lt;code&gt;89.0&lt;/code&gt;. Why does this happen? And why the reverse is not possible? Why do we get an error when given a &lt;code&gt;float&lt;/code&gt; to an &lt;code&gt;int&lt;/code&gt; type variable?&lt;/p&gt;

&lt;p&gt;All of this can be understood by learning about type conversion and casting.&lt;/p&gt;
&lt;h3&gt;
  
  
  Conditions for Type Conversion
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Two types should be compatible

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;char&lt;/code&gt; &amp;amp; &lt;code&gt;String&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;int&lt;/code&gt; &amp;amp; &lt;code&gt;float&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Destination type should be greater than source type&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;float&lt;/code&gt; is greater than &lt;code&gt;int&lt;/code&gt; cause in addition to integers it also contains decimal numbers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tEQfsxQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636987816952/ELZr6M7x4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tEQfsxQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636987816952/ELZr6M7x4.png" alt="image.png" width="364" height="156"&gt;&lt;/a&gt;&lt;br&gt;
Due to this condition, &lt;code&gt;float&lt;/code&gt; does not get converted to &lt;code&gt;int&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In some situations, we might want to convert all our data into a particular datatype which we can do explicitly. This is known as Type-casting.&lt;/p&gt;

&lt;p&gt;For example, if we want all our data in &lt;code&gt;int&lt;/code&gt; type by default and we want our program to tackle the condition where a user might input a float number. then we can convert the input number into integer explicitly using the following instruction&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num = (int)(input.nextFloat)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now even if the user inputs a float number it will be accepted without any error because we have used the &lt;code&gt;nextFloat()&lt;/code&gt; method instead of &lt;code&gt;nextInt()&lt;/code&gt;. It will then be converted to integer type as our code demands.&lt;/p&gt;

&lt;p&gt;Example,&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int num = (int)(1323.79f)
System.out.println(num)

output:
1323
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This was all about Typecasting and data types. Have a look at the git repo below to start with some basic programs and try to understand and run them. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Raj-Pansuriya"&gt;
        Raj-Pansuriya
      &lt;/a&gt; / &lt;a href="https://github.com/Raj-Pansuriya/java-dsa"&gt;
        java-dsa
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Change the program and play with them. You can always connect with me in case you have any doubts&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;Twitter&lt;/a&gt; &lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;LinkedIn&lt;/a&gt; &lt;a href="https://github.com/Raj-Pansuriya/"&gt;GitHub&lt;/a&gt;                                                 &lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>I/O in JAVA</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Sat, 13 Nov 2021 18:26:12 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/io-in-java-1hl7</link>
      <guid>https://dev.to/rajpansuriya/io-in-java-1hl7</guid>
      <description>&lt;p&gt;In our last article, we discussed everything but the output statement in our sample code. Let us explore inputs, outputs, classes responsible for I/O and packages in Java.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a package in Java
&lt;/h2&gt;

&lt;p&gt;In simple terms, a package is nothing but a folder in which our Java file will lie. Sometimes we may want to have a set of rules for our code files like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A function should be accessed by files in that folder only&lt;/li&gt;
&lt;li&gt;A class and its methods should be accessed by particular folder files only&lt;/li&gt;
&lt;li&gt;A file should be accessed by files in the &lt;code&gt;app&lt;/code&gt; folder.
It's scenarios like this when we can make use of packages and access modifiers. If you do not know what an access modifier is, no worries because we will be discussing that in detail later on. We have even used an access modifier named &lt;code&gt;public&lt;/code&gt; which I explained in the last article.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might stumble upon packages now and then in your java code. Especially if you use an IDE because IDE's are set to create a package for our program by default. Even if you do not use any IDE, you might use packages efficiently to have some security for your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outputs in Java
&lt;/h2&gt;

&lt;p&gt;We know that everything in Java works in classes. Java language provides us with some basic functionalities such as input, output, debugging, etc. which we can use while writing our program. &lt;/p&gt;

&lt;p&gt;One such functionality is when we have to print something on our console. We use &lt;code&gt;print&lt;/code&gt; or &lt;code&gt;println&lt;/code&gt; function to print something on our console.&lt;/p&gt;

&lt;p&gt;Now Java has a class called &lt;code&gt;System&lt;/code&gt; in &lt;code&gt;java.lang&lt;/code&gt; package (language package). You can open the file and inspect the System class if your Development environment (IDE or Text editor) supports it. You can try clicking on &lt;code&gt;System&lt;/code&gt; while holding the &lt;code&gt;ctrl&lt;/code&gt; key to open System class.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o01f-eTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636819197687/LDb5WE38c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o01f-eTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636819197687/LDb5WE38c.png" alt="image.png" width="711" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;System&lt;/code&gt; class has a variable of type &lt;code&gt;PrintStream&lt;/code&gt; named &lt;code&gt;out&lt;/code&gt; that is used to print some output when given a stream of characters. The &lt;code&gt;out&lt;/code&gt; variable has various functions for giving various types of output. One of them is the &lt;code&gt;println&lt;/code&gt; function which prints character output when given character input. In a nutshell, by writing &lt;code&gt;System.out.println()&lt;/code&gt; we are accessing the &lt;code&gt;println&lt;/code&gt; function to have the required output. Memorize it for now if any of the above does not make sense to you.  It will make more sense when you know a bit more about classes.&lt;/p&gt;
&lt;h3&gt;
  
  
  print vs println
&lt;/h3&gt;

&lt;p&gt;Both the function give us a standard output on the console with a minor difference that &lt;code&gt;println&lt;/code&gt; adds a new line to the output. Take a look at the example below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Hello {
    public static void main(String[] args) {
        System.out.print("Hello World!!");
        System.out.print("My name is Raj!");
    }
}

output:
Hello World!!My name is Raj!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello World!!");
        System.out.println("My name is Raj!");
    }
}

output:
Hello World!!
My name is Raj!

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, a new line gets added at the end when we use &lt;code&gt;println&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inputs in Java
&lt;/h2&gt;

&lt;p&gt;As we have a &lt;code&gt;System&lt;/code&gt; class for handling outputs, in the same way we have a class to handle inputs in Java known as the &lt;code&gt;Scanner&lt;/code&gt; class. It's available in the &lt;code&gt;java.util&lt;/code&gt; package. To use that class first we have to import &lt;code&gt;java.util&lt;/code&gt; package in our program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now how do we use a class, we create an object of it. &lt;code&gt;new&lt;/code&gt; is the keyword used to make objects of a class. Now Scanner class has to be given an argument stating the source from where input is coming. The input may be from a file, it may be from a database, etc. In our case input is from the keyboard, so we will pass &lt;code&gt;System.in&lt;/code&gt;&lt;br&gt;
The syntax for this is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;
public class Hello {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now using object &lt;code&gt;input&lt;/code&gt; we can take inputs from our user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;

public class Input {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("please provide some input");

        System.out.println(input.next());
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The given program will take input from the user and then output it as it is. We have used the &lt;code&gt;input.next()&lt;/code&gt; method which is used to take string inputs (Character type input). There are several other methods to have inputs of various data types.&lt;/p&gt;

&lt;p&gt;We'll see those methods in our next article while we explore various datatypes supported by java. Till then feel free to connect with me on&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;Twitter&lt;/a&gt; &lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;LinkedIn&lt;/a&gt; &lt;a href="https://github.com/Raj-Pansuriya/"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>Structure of JAVA Code</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Fri, 12 Nov 2021 08:16:57 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/structure-of-java-code-3oda</link>
      <guid>https://dev.to/rajpansuriya/structure-of-java-code-3oda</guid>
      <description>&lt;p&gt;Till our last article, we have JDK installed in our system. Now we are all set to write our first Java code. You can make a separate directory (recommended) to contain all your java codes and projects&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir dsa_with_java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now to create a new java file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd dsa_with_java
$ touch Hello.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Have a look at the java code below. This is how a very basic java code looks like. It might feel overwhelming at first to know that we have to write so much just to have &lt;code&gt;Hello World!!&lt;/code&gt; as output, but once we discuss all the building blocks of the code everything will start making sense&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello World!!");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will discuss everything that we have written in the code snippet shortly, but first, let's try and apply what we have already learned. Let's try and generate a byte code from the given code and try to have some output on our console.&lt;br&gt;
As you can see, we only have a .java file currently in our folder. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NXSebTgt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636699857397/niTJWf2nN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NXSebTgt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636699857397/niTJWf2nN.png" alt="image.png" width="827" height="320"&gt;&lt;/a&gt;&lt;br&gt;
Let's use the javac compiler to generate a .class byte code file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ javac Hello.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sm4XgyMo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636700116593/b5u8MUndl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sm4XgyMo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636700116593/b5u8MUndl.png" alt="image.png" width="880" height="587"&gt;&lt;/a&gt;&lt;br&gt;
This is the file responsible for the platform independence of the Java language. That means, we can share this file with anyone irrespective of the Operating system he/she is using and they would be able to run the program just fine. Let's try and run the program now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ java Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pjDs2sGU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636700409654/Ao-66tVGw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pjDs2sGU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636700409654/Ao-66tVGw.png" alt="image.png" width="578" height="188"&gt;&lt;/a&gt;&lt;br&gt;
Voila!!! We have successfully written and run our first java program.&lt;br&gt;
Now let's understand all the things that we wrote in our code and their significance. You might not understand some of these keywords which is fine because it will start making sense once we learn object-oriented programming. So if you get everything now, it's well and good, but even if you do not get some things it's OK!!&lt;/p&gt;

&lt;h2&gt;
  
  
  Some important things about a Java code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Everything we write in java is going to be in &lt;em&gt;classes&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Every file with a .java extension is a class itself&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Hello&lt;/code&gt; class in &lt;code&gt;Hello.java&lt;/code&gt; has to be public. You can not have a class named anything other than the file name. for example a file name Main.java has to have a public class named Main&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;public&lt;/strong&gt;: public means the class can be accessed from anywhere&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;class&lt;/strong&gt;: class keyword tells java to make a class. for example &lt;code&gt;class Hello&lt;/code&gt; means make a class named &lt;code&gt;Hello&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;main function&lt;/strong&gt;: Inside this public class we create a function named &lt;code&gt;main&lt;/code&gt;. By convention, a java file must have a &lt;code&gt;main&lt;/code&gt; function. It's the entry point for any java code. If there is no &lt;code&gt;main&lt;/code&gt; function we won't be able to run that code. A function is nothing but a bunch of instructions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;public for function&lt;/strong&gt;: by writing public in line 2, we are making our main function public to all other modules. Think about it, We just said that the &lt;code&gt;main&lt;/code&gt; function is the entry point of our program. So does it not make sense to make it public so even other classes can also access it. That is the reason we always have our main function declared public.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;static&lt;/strong&gt;: Understand one thing, that if you have to use data or function of a class, you have to create an object of that class, and then only you can use those functions and data. Now &lt;code&gt;main&lt;/code&gt; is the entry point of java. That means nothing exists in terms of code before executing the &lt;code&gt;main&lt;/code&gt; function. But to use the main function we'll have to create an object of the &lt;code&gt;Hello&lt;/code&gt; class. So we are stuck in a contradictory loop. To use a function we must have an object, but to create an object we should run the main function. So the thing is, we want to execute this &lt;code&gt;main&lt;/code&gt; function without creating an object of &lt;code&gt;Hello&lt;/code&gt; class. &lt;code&gt;static&lt;/code&gt; is the keyword which provides us that power. &lt;code&gt;main&lt;/code&gt; is the function that does not depend on objects and classes. Hence, it has to be a static function&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;void&lt;/strong&gt;: void is the return type of function. In java, every function has its return type.
for example, if we write a function to add two integers, its return type would be &lt;code&gt;int&lt;/code&gt; because, in the end, the function will return us an integer (sum of two integers). In the same way, our main function here is just printing a simple message &lt;code&gt;Hello World!&lt;/code&gt; and is not returning anything. Hence the return type void&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;String[] args&lt;/strong&gt;: These are known as command-line arguments. We can provide command-line arguments to our program and make our code execute in a particular way.&lt;/li&gt;
&lt;li&gt;We'll explore more about &lt;code&gt;System.out.println&lt;/code&gt; in our coming articles. For now, consider it as a way to output some characters on the console.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tips while writing a java code.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;By convention, we write a class name in CapitalCase. It does not make any difference in the logic of the code even if you write it in a small case but it's a good practice to follow conventions of the language we are coding in.&lt;/li&gt;
&lt;li&gt;If you do not want your java code and byte code in the same folder you can do that by passing the &lt;code&gt;-d&lt;/code&gt; flag to the java compiler. This is a good practice actually to keep all your source code (.java files) in the &lt;code&gt;src&lt;/code&gt; folder and all the byte code in the &lt;code&gt;out&lt;/code&gt; folder. It makes things well structured and organized.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ javac -d location/to/save/byte/code file.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qrnz24QI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636703313966/0YWMvtjIg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qrnz24QI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636703313966/0YWMvtjIg.png" alt="image.png" width="880" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all for this article. In the next article, we'll explore supported data types by Java. Till then feel free to connect with me on my socials.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;linkedin&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/Raj-Pansuriya/"&gt;github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Getting Started with Java - Installation</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Thu, 11 Nov 2021 13:15:52 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/getting-started-with-java-installation-5l3</link>
      <guid>https://dev.to/rajpansuriya/getting-started-with-java-installation-5l3</guid>
      <description>&lt;p&gt;You can install the latest version of java for Windows and macOS from its official site. For Linux-based distributions command line is the recommended option. Follow the instructions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install java for &lt;a href="https://www.oracle.com/java/technologies/downloads/#jdk17-mac"&gt;MacOS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install java for &lt;a href="https://www.oracle.com/java/technologies/downloads/#jdk17-windows"&gt;Windows&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install java for &lt;a href="https://www.oracle.com/java/technologies/downloads/#jdk17-linux"&gt;linux&lt;/a&gt;
Note: Though you can download and install JDK for Linux from the official site, I would highly recommend you to use the official package manager for your distribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Java on Linux distributions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Ubuntu, Debian, and distributions that use &lt;strong&gt;apt&lt;/strong&gt; as the package manager&lt;br&gt;
Open your terminal and follow the guide&lt;/p&gt;

&lt;p&gt;Update the package index&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get update
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Check if Java is not already installed:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ java --version
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;If Java is already installed we'll get output similar to below&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12)
OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;If not, then install java&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get install default-jdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For arch and arch-based distributions&lt;/p&gt;

&lt;p&gt;Update the system&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo pacman -Syyu
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Check if Java is not already installed:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ java --version
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Search for available JRE in the arch repository&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pacman -Ss java | grep jre
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V7UO3cN---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636607547791/t-klDRH8W.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V7UO3cN---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636607547791/t-klDRH8W.png" alt="image.png" width="488" height="224"&gt;&lt;/a&gt;&lt;br&gt;
Install the latest jre&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo pacman -S jre-openjdk
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Similarly, search for the latest JDK and install it&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pacman -Ss java | grep jdk
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j1KHyLRm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636607674128/WRL8RwQJ4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j1KHyLRm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1636607674128/WRL8RwQJ4.png" alt="image.png" width="584" height="546"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo pacman -S jdk-openjdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next thing you may want to install is an Integrated Development Environment (IDE). There are so many IDE's available for Java development. One of the best being &lt;a href="https://www.jetbrains.com/idea/download"&gt;IntelliJ IDEA&lt;/a&gt;. You may even consider setting a Java Development Environment in your preferred text editor such as &lt;a href="https://code.visualstudio.com/"&gt;VSCode&lt;/a&gt; or &lt;a href="https://atom.io/"&gt;Atom&lt;/a&gt;, etc. I leave these things to your liking.&lt;/p&gt;

&lt;p&gt;That's all for this one. Feel free to connect with me&lt;br&gt;
&lt;a href="https://twitter.com/Raj_Pansuriya7"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HxHaoR44--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Twitter-Profile-informational%3Fstyle%3Dflat%26logo%3Dtwitter%26logoColor%3Dwhite%26color%3D1CA2F1" alt="Twitter logo" width="111" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/raj-pansuriya/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pjPRRZcU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/LinkedIn-Profile-informational%3Fstyle%3Dflat%26logo%3Dlinkedin%26logoColor%3Dwhite%26color%3D0D76A8" alt="LinkedIn Badge" width="119" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>codenewbie</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introduction to Java - Compiler Architecture</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Wed, 10 Nov 2021 15:06:08 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/introduction-to-java-compiler-architecture-3id9</link>
      <guid>https://dev.to/rajpansuriya/introduction-to-java-compiler-architecture-3id9</guid>
      <description>&lt;p&gt;In previous articles, we discussed that we write all our code in a human-readable format. We also got to know that computers can only understand machine language i.e., the language of 0's &amp;amp; 1's. We know that there is an intermediate agent known as a compiler that translates human-readable code to machine-readable code.&lt;/p&gt;

&lt;p&gt;In this article, we'll be exploring more about compiler (Java compiler in depth). We'll look into the basic building blocks of java, how a java code executes, the basics of java language, how everything works internally from writing a java code to its execution, what are the different components of the java compiler, and so on.&lt;/p&gt;

&lt;p&gt;While exploring our computer storage, one might observe that different types of files possess different extensions. a PowerPoint file have .pptx extension, a doc file have .docx extension, a pdf file have .pdf file extension, a picture may have .jpg/.png extension etc. In the same way, a java file will have a &lt;strong&gt;.java&lt;/strong&gt; extension.&lt;/p&gt;

&lt;p&gt;So the .java file will contain all our code in human-readable form. The code might be any set of instructions as per rules (syntax) of the Java language.&lt;/p&gt;

&lt;h2&gt;
  
  
  How JAVA is Platform Independent
&lt;/h2&gt;

&lt;p&gt;In some programming languages such as C, C++ the compiler converts the .c or .cpp file directly into machine code giving us a .exe file that is platform dependent. If we try to execute such a .exe file on a different Operating System (OS) than what it was created on, we won't be able to do so. Once the type of OS is changed, the code needs to be re-compiled. This means a c/c++ code compiled on windows will not execute on a Linux OS or a MAC OS and vice-versa.&lt;/p&gt;

&lt;p&gt;Unlike those programming languages, when a java compiler compiles a .java file, it converts it into something known as &lt;strong&gt;byte code&lt;/strong&gt;. Some important points about byte code are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This code file will have &lt;em&gt;.class&lt;/em&gt; extension&lt;/li&gt;
&lt;li&gt;This code will still not be understood by a computer, which means it won't directly run on a system&lt;/li&gt;
&lt;li&gt;We'll need something called Java Virtual Machine (JVM) to execute this code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now one might have so many different questions such as what is byte code? Why do we have a byte code? What is JVM? What does JVM do? How does all of this relate to the platform independence of JAVA? etc. Let's answer all of them one by one.&lt;/p&gt;

&lt;p&gt;Consider byte code as some intermediate language of java. Java Virtual Machine acts as an interpreter for byte code. That means when the byte code is run by JVM, it gets converted to machine code and hence is finally ready to be executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636539931785%2FXaPY_GW3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636539931785%2FXaPY_GW3s.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The byte code once compiled, can be used to generate machine code on all types of operating systems. Say a byte code is generated on macOS, we can still use that byte code to generate machine code on Linux/Windows OS. This is how Java gets its platform-independent behavior because, unlike other programming languages, we do not have to recompile the program every time we change our OS.&lt;/p&gt;

&lt;h4&gt;
  
  
  More on Platform Independence
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;byte code (.class file) can run on all operating systems.&lt;/li&gt;
&lt;li&gt;JVM converts the byte code into machine code.&lt;/li&gt;
&lt;li&gt;JAVA is platform-independent, but JVM is not.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Architecture of JAVA
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636541833244%2FI5nifrMjW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636541833244%2FI5nifrMjW.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Java Development Kit (JDK)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Provides an environment to develop and run Java programs&lt;/li&gt;
&lt;li&gt;It is a package that consists of :

&lt;ol&gt;
&lt;li&gt;Development tools: Provide an environment to develop a java program&lt;/li&gt;
&lt;li&gt;Java Runtime Environment (JRE): to execute java programs&lt;/li&gt;
&lt;li&gt;A compiler &lt;strong&gt;javac&lt;/strong&gt;: Converts java code into byte code. ( .java -&amp;gt; .class )&lt;/li&gt;
&lt;li&gt;Archiver &lt;strong&gt;jar&lt;/strong&gt;: If we want to archive our files&lt;/li&gt;
&lt;li&gt;Docs generator &lt;strong&gt;javadoc&lt;/strong&gt;: to generate docs of our application&lt;/li&gt;
&lt;li&gt;interpreter &amp;amp; loader&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;In short, if we want to write and develop java codes, we need to have JDK&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Java Runtime Environment (JRE)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It is a package that provides an environment to &lt;em&gt;only run&lt;/em&gt; the java programs&lt;/li&gt;
&lt;li&gt;It consists of :

&lt;ol&gt;
&lt;li&gt;Deployment Technologies&lt;/li&gt;
&lt;li&gt;User Interface toolkits&lt;/li&gt;
&lt;li&gt;Integration Libraries&lt;/li&gt;
&lt;li&gt;Base libraries&lt;/li&gt;
&lt;li&gt;JVM&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;After we get the byte code ( .class file ), at run time:

&lt;ol&gt;
&lt;li&gt;loader loads all the necessary classes needed to execute the program.&lt;/li&gt;
&lt;li&gt;JVM sends code to &lt;em&gt;byte code verifier&lt;/em&gt; to check the format of the code.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Compile Time
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636550710827%2FrlEBpPKAY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636550710827%2FrlEBpPKAY.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During compile-time, the source code written by us ( .java file) is coverted t byte code ( .class file) by java compiler (javac).&lt;/p&gt;

&lt;h4&gt;
  
  
  Run Time
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636550875244%2FcO-n5RzrY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636550875244%2FcO-n5RzrY.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most of the runtime period is dominated by &lt;strong&gt;JVM&lt;/strong&gt; and its components.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;Class loader (Working of JVM)&lt;/strong&gt;
&lt;/h6&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Loading :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reads .class file and generate binary data in form of object&lt;/li&gt;
&lt;li&gt;The object of .class is generated in heap memory. The object contains source code, necessary data, any other necessary java libraries which we may have referenced in our code, etc.&lt;/li&gt;
&lt;li&gt;In simple terms, we can say that the program is loaded in the RAM of the computer in the loading process&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Linking :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JVM verifies the .class file to avoid any errors/any things prohibited by Java&lt;/li&gt;
&lt;li&gt;Allocates memory for class variables &amp;amp; default values because all the variables, constants, functions, methods, etc. needs to be allocated the proper amount of memory in RAM&lt;/li&gt;
&lt;li&gt;Replace all the symbolic references with direct references.
for example, if our code has a statements
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 10
b = 20
c = a + b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then &lt;code&gt;a&lt;/code&gt; has to be replaced with 10, &lt;code&gt;b&lt;/code&gt; with 20, and &lt;code&gt;c&lt;/code&gt; with 10+20.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialization :

&lt;ul&gt;
&lt;li&gt;All static variable are assigned their values defined in the code and static block.
We'll be seeing static variables in detail in our further articles when we'll discuss OOP. For now, understand static variables as variables that are independent of the object of the class.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we have source code, data, and other libraries properly loaded, verified, and linked; it's time to generate machine code from that.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;strong&gt;JVM Execution&lt;/strong&gt;
&lt;/h6&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Interpreter :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Line by line execution of .class file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: Because the interpreter interprets the byte code line-by-line, it will read and interpret any function or variable over and over again if every time it's called. That means a function is converted to machine code every time it's used in source code, which is not really efficient. To solve this problem we have, Just in Time compiler ( JIT ).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Just In Time Compiler ( JIT ) :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JIT provides direct machine code for methods that are repeated in source code to avoid re-interpretation&lt;/li&gt;
&lt;li&gt;Makes execution faster&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  JRE vs JVM
&lt;/h4&gt;

&lt;p&gt;Think of JRE as a box and JVM as the content inside the box, the main working machine being JVM. JVM does all the necessary processing on source code but the things which JVM might require such as dependent libraries, base libraries in order to do that procession are held and provided by JRE. Whenever JVM needs any help, its main point of contact is JRE.&lt;/p&gt;

&lt;p&gt;We can say that &lt;code&gt;JRE = JVM + some other files &amp;amp; tools&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Collectively
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636555326553%2F37XAWqZRv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1636555326553%2F37XAWqZRv.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We write java code in human-readable form&lt;/li&gt;
&lt;li&gt;Compiler javac inside JDK compiles it to form a .class file of byte code&lt;/li&gt;
&lt;li&gt;JVM runs and the byte code and give us an executable code which is then run via JRE&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Reference
&lt;/h4&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4EP8YzcN0hQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In next article, we'll start with our &lt;code&gt;Hello World&lt;/code&gt; Java code. Till then feel free to connect with me on my socials!!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Flow of Program</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Tue, 09 Nov 2021 08:15:19 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/flow-of-program-b1f</link>
      <guid>https://dev.to/rajpansuriya/flow-of-program-b1f</guid>
      <description>&lt;p&gt;In this article we'll learn about control flows, flowcharts and pseudocode of a program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flowcharts
&lt;/h2&gt;

&lt;p&gt;Flowcharts is just a visual represemtation of the logic we think or an algorithm we create to solve a particular problem.&lt;br&gt;
As every language we speak has some sort of grammer and rules to follow, think of flowcharts as a pictorial language where certain symbols carry specific meanings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmqzpihfy44irmoyj6hw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmqzpihfy44irmoyj6hw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;start/end: indicates Start or End of the program&lt;/li&gt;
&lt;li&gt;arrows: Used to relate various representative shapes. Used to show flow direction of the program &lt;/li&gt;
&lt;li&gt;input/output: Input that we take from user and output that we provide to our user&lt;/li&gt;
&lt;li&gt;process: Anything and everything (operations) that we do on imput data to produce output data&lt;/li&gt;
&lt;li&gt;decision: We use this shape to decide between one or more options to proceed further. For example, we might want to change flow of our code based upon the fact whether a student got more or less than 60 marks in exam&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let us understand these things using some simple examples...&lt;br&gt;
1.Take a name from user and print 'Hello name'&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74segth713uitnmb7chj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74segth713uitnmb7chj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.Take salary input form user. Add a bonus of Rs.2000 if the salary is greater than Rs.10000 else add a bonus of Rs.1000&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzgo92vnjlfzr00p723j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzgo92vnjlfzr00p723j.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above flowchart, we used diamond shape to write an if statement (if salary&amp;gt;1000)&lt;/p&gt;

&lt;p&gt;3.Input a number and print whether its prime or not&lt;/p&gt;

&lt;p&gt;We know that &lt;em&gt;prime numbers&lt;/em&gt; numbers are the numbers which are only divisible by 1 &amp;amp; the number itself. So the 1st thought to approach this problem could be,&lt;/p&gt;

&lt;p&gt;Check for all the numbers between 1 &amp;amp; the target number, if any number divides the target number. If any of them can completely divide the target number then the target number is not prime otherwise its a prime number.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jtx8sud7uxkkfiaprhe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jtx8sud7uxkkfiaprhe.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above flowchart, there is a &lt;code&gt;%&lt;/code&gt; operator which some of you might not be familiar with. &lt;code&gt;%&lt;/code&gt; operator basically shows reminder when number at LHS (left hand side) is divided by number at RHS (right hand side)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4 % 2 =0   # because 4 is completely dividible by 2
5 % 2 =1   # because 2x2 is 4 and 1 is the reminder of division
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another thing which one can observe is that we have created a loop to check all the numbers between 1 &amp;amp; the target number. Its also evident from the flowchart cause we have a cyclic figure between the conditions, signifying a loop. We will learn about loops in depth in out further articles, for now I just want you to get a basic gist of it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Pseudocode
&lt;/h2&gt;

&lt;p&gt;Sometimes we want to share our logic or algorithm with someone and we really do not care about the rules of programming language that the person want to use. We just need to share our logic irrespective of the syntactical specifications. At such times we can use pseudocode. Pseudocode in simple terms can be stated as a rough code for our logic.&lt;/p&gt;

&lt;p&gt;Lets try and understand this with our previous example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;START
input num
count = 2
while count &amp;lt;= num:
    if (num % count)=0:
        output "NOT Prime"
    count = count + 1
end while
output "Prime"
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see we use if conditions and loops as conditionsals. We also used them in the flowchart. One can say that flowchart and pseudocodes are just different ways of representing a logic or an algorithm without caring about syntax (A rough idea of the code.)&lt;/p&gt;

&lt;p&gt;Now lets try and optimize above logic. Lets take example of number 28&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Factors of 28
1x28 = 28
2x14 = 28
4x7 = 28
7x4 = 28
14x2 = 28
28x1 = 28
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what we were doing in the prime number example, we were looking for all the factors of a number and if any number has more than 2 (1 &amp;amp; the target number) factors then the number is not prime.&lt;/p&gt;

&lt;p&gt;In the above cell we can see that there is repetetion when we check for those factors. Once we have checked &lt;code&gt;2x14=28&lt;/code&gt; there is no need to check &lt;code&gt;14x2=28&lt;/code&gt; agian. We are repeating ourselves. This unnecessarily increases time &amp;amp; memory required to process our code.  So check only for&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Factors of 28
1x28 = 28
2x14 = 28
4x7 = 28
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;del&gt;7x4 = 28&lt;/del&gt;&lt;br&gt;
&lt;del&gt;14x2 = 28&lt;/del&gt;&lt;br&gt;
&lt;del&gt;28x1 = 28&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;Similarly for &lt;code&gt;36&lt;/code&gt; we check only till &lt;code&gt;6&lt;/code&gt; for &lt;code&gt;49&lt;/code&gt; we check only till &lt;code&gt;7&lt;/code&gt; and so on. If we observe carefully we can easily find the pattern. For every target number, we only have to check till its square root&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqrt(28)=5.29
sqrt(36)=6
sqrt(49)=7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These minute changes might feel insignificant when we are dealing with smaller numbers like &lt;code&gt;28&lt;/code&gt;, &lt;code&gt;36&lt;/code&gt;, and &lt;code&gt;49&lt;/code&gt; but tehy make huge difference when the target number is in millions or billions.&lt;/p&gt;

&lt;p&gt;for example, if we want to check prime status of a number &lt;code&gt;876187398013&lt;/code&gt; it will require 876187398013 iterations by our initial logic but only sqrt(876187398013) = &lt;strong&gt;936048&lt;/strong&gt; iterations by our optimized logic.&lt;/p&gt;

&lt;p&gt;So our optimized pseudocode and the flowchart for the program is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;START
input num
count = 2
while count &amp;lt;= sqrt(num):
    if (num % count)=0:
        output "NOT Prime"
    count = count + 1
end while
output "Prime"
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;flowchart&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewjwxwyzim0fwph9fxqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewjwxwyzim0fwph9fxqr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope ya'll have got an idea of how the flow direction of program works and how we can tray and test our logic without actually writing the code using flowcharts and pseudocodes.&lt;/p&gt;
&lt;h4&gt;
  
  
  Reference
&lt;/h4&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/lhELGQAV4gg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Introduction to Programming</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Mon, 08 Nov 2021 15:15:41 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/introduction-to-programming-169p</link>
      <guid>https://dev.to/rajpansuriya/introduction-to-programming-169p</guid>
      <description>&lt;h2&gt;
  
  
  Programming
&lt;/h2&gt;

&lt;p&gt;Programming in simple terms can be stated as a way of instructing computer to perform some task. We write a code and pass it to computer and the computer then performs tasks accordingly. The computer can only understand language of 0's and 1's, so we can say that programming at its heart is nothing but passing a stream of 0's and 1's computer.&lt;br&gt;
Now, if internally its only 0's and 1's it would be very difficult for us to write all the instruction as a combination of 0's and 1's only. That is the reason we have different programming languages which allow us to write all those instructions in human redable format. Eventually computer is going to translate all that code into 0's and 1's but atleast we are saved from the the pain of writing all instructions in its naive form.&lt;/p&gt;
&lt;h2&gt;
  
  
  Types of programming languages
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Procedural language&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;These types of languages follow a top-bottom approach. That means, a series of well structured steps and procedures are specified to compose a program&lt;/li&gt;
&lt;li&gt;It contains a systematic order of statements, functions and commands to complete a task
for example
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input 1st no.
input 2nd no.
add both numbers
print the answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Functional languages&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;In this programming approach, we write a code in pure functions only. A function in simple language is a block of code (set of instructions) bundled together.&lt;/li&gt;
&lt;li&gt;Used in situations where we have to perform the different operations on same type of data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, let's say we have to print number of words containing in files and have 20 such files. Does it make sense to write the same code from scratch for each file. Instead what we can do is write a function to do the task and then just pass each file to that function (or in simple terms apply that function to each file).&lt;/p&gt;

&lt;p&gt;Doing this not only saves time but is also helpful when we want to change the code due to some reason. Intead of having to chnage 20 differnet code files we can simply change the general function and we are good to go!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These types of language follow &lt;strong&gt;&lt;em&gt;first class function&lt;/em&gt;&lt;/strong&gt; properties.
If we can reassign a function to another function then the language is said to follow first class function properties. for example,
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function_1:
    some code block

instruction 1
instrcution 2

function_2=function_1
# here we assigned function_2 to be equal to function_1.
# This is known as 1st class function behaviour
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;An example of such programming language can be &lt;em&gt;python&lt;/em&gt;. Mind that python may not follow purely functional language approach, I'm just saying that python does have first class functions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Object Oriented Programming (OOP)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Revolves around objects&lt;/li&gt;
&lt;li&gt;object = code + data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's say we have to gift 10 fruit baskets to our friends. We collected (40-Apples), (50-Oranges) and (70-Bsnanas) and divided them equally in those baskets. Now if someone asks us what fruit are we giving them, we do not have a single answer as the basket is composed of three different types of fruits. So then whats going to be the collective type of the basket. It'll be a custom type.&lt;/p&gt;

&lt;p&gt;In the same way, when we are to group data of different datatypes like integer,decimal,character etc. the collective datatype of the data is custom datatype and one single unit of that data is said an object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;So the idea of OOP is to divide the code into different chunks of code in order to develope, debug, reuse and maintain the software efficiently.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Static vs Dynamic languages
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Static&lt;/th&gt;
&lt;th&gt;Dynamic&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Type checking is done at compile time.&lt;code&gt;int a = 10&lt;/code&gt;, we have to specify the type of &lt;code&gt;a&lt;/code&gt; before assigning it a value.&lt;/td&gt;
&lt;td&gt;Type checking is done at runtime.&lt;code&gt;a = 10&lt;/code&gt;,  computer will automatically understand that &lt;code&gt;a&lt;/code&gt; is of integer type as the values assigned is 10.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Errors will be shown at compile time.`int a = 25.4' will give an error after the compilation itself because we are assigning a decimal to an int type integer.                                                                                                                                                                                                                                                                                 &lt;/td&gt;
&lt;td&gt;Errors might not show till the program is run.&lt;code&gt;'a' + 10 //ERROR&lt;/code&gt; all the statements before this particular statement will get executed (if none of them has any error ofcourse) and at the time of this statement itself we get an error because we are trying to add and integer and a character&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;We have to declare datatype before using a variable &lt;code&gt;int a = 10&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;No need to declare the datatype &lt;code&gt;a = 10&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;We may have to write a little more code as compared to dynamic language, but we have more control over the program.&lt;/td&gt;
&lt;td&gt;Saves time in writing code but might give an error at runtime.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now that we have got a basic background, let's try and understand some basic things which occur when we write some code.&lt;/p&gt;
&lt;h2&gt;
  
  
  Memory Management
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;a = 10&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the given instruction, &lt;code&gt;a&lt;/code&gt; is known as a &lt;strong&gt;&lt;em&gt;reference-variable&lt;/em&gt;&lt;/strong&gt; and the value &lt;code&gt;10&lt;/code&gt; is known as an &lt;strong&gt;&lt;em&gt;object&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two types of memories namely &lt;strong&gt;&lt;em&gt;heap-memory&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;stack-memory&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xqb0ghehz261vuz5ojl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xqb0ghehz261vuz5ojl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the instruction &lt;code&gt;a = 10&lt;/code&gt; is executed, the variable &lt;code&gt;a&lt;/code&gt; is stored in stack-memory and it &lt;em&gt;points&lt;/em&gt; towards the object 10 which is stored in heap-memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6yt8u7i44le21yb8mga.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6yt8u7i44le21yb8mga.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So whenever our code needs to access the value of &lt;code&gt;a&lt;/code&gt;, it looks into stack by which it gets a pointer to a value of heap memory upon following which it gets actual value of the variable &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Important
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;More than one reference variables can point to same object&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for example same person is called by different names by his family, friends teachers, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4e0jlzk48qxcrk204j8y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4e0jlzk48qxcrk204j8y.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Value of an object is changes for all the reference variables even if it is changed by any one reference variable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for example, if the person named Kunal has lunch, automatically baby, son and brother also had lunch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Objects with no reference variables are removed when garbage collection hits and the memory is freed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for example,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a = 10&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9yexk2iguohoudkykv43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9yexk2iguohoudkykv43.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Now,we reassign a to 37&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a = 37&lt;/code&gt;&lt;br&gt;
 &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3pqqjvr8l68e1h422jj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3pqqjvr8l68e1h422jj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the 10 will be removed from memory by garbage collector and the memory will be freed&lt;/p&gt;

&lt;p&gt;Note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compile time&lt;/strong&gt;: The period where code from human redable format is being converted to machine redable format(machine code; 0's &amp;amp; 1's)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run time&lt;/strong&gt;: The period where our code is being executed&lt;/li&gt;
&lt;li&gt;There are no separate partitions or disks as heap and stack, it is just how the memory is managed by CPU. There is only one RAM which is managed in the said way&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Reference
&lt;/h4&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/wn49bJOYAZM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>languages</category>
    </item>
    <item>
      <title>EOFError: EOF when reading a line</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Fri, 12 Feb 2021 12:27:32 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/eoferror-eof-when-reading-a-line-12fe</link>
      <guid>https://dev.to/rajpansuriya/eoferror-eof-when-reading-a-line-12fe</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft0wox8ydnvia5f0fankb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft0wox8ydnvia5f0fankb.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fasqw4ut2g7m1612lwkye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fasqw4ut2g7m1612lwkye.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
So as we can see in the pictures above, despite having produced the expected output, our test case fails due to a runtime error &lt;strong&gt;EOFError&lt;/strong&gt; i.e., &lt;em&gt;End of File Error&lt;/em&gt;. Let's understand what is EOF and how to tackle it.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is EOFError
&lt;/h3&gt;

&lt;p&gt;In Python, an EOFError is an exception that gets raised when functions such as input() or raw_input() in case of python2 return end-of-file (EOF) without reading any input.&lt;/p&gt;

&lt;h3&gt;
  
  
  When can we expect EOFError
&lt;/h3&gt;

&lt;p&gt;We can expect EOF in few cases which have to deal with input() / raw_input() such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Interrupt code in execution using &lt;code&gt;ctrl+d&lt;/code&gt; when an input statement is being executed as shown below&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fprvwhru3jhw90b6wn88m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fprvwhru3jhw90b6wn88m.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Another possible case to encounter EOF is, when we want to take &lt;em&gt;some&lt;/em&gt; number of inputs from user i.e., we do not know the exact number of inputs; hence we run an infinite loop for accepting inputs as below, and get a Traceback Error at the very last iteration of our infinite loop because user does not give any input at that iteration&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;n=int(input())&lt;br&gt;
if(n&amp;gt;=1 and n&amp;lt;=10**5):&lt;br&gt;
    phone_book={}&lt;br&gt;
    for i in range(n):&lt;br&gt;
        feed=input()&lt;br&gt;
        phone_book[feed.split()[0]]=feed.split()[1]&lt;br&gt;
    while True:&lt;br&gt;
        name=input()&lt;br&gt;
        if name in phone_book.keys():&lt;br&gt;
            print(name,end="")&lt;br&gt;
            print("=",end="")&lt;br&gt;
            print(phone_book[name])&lt;br&gt;
        else:&lt;br&gt;
            print("Not found")&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The code above gives EOFError because the input statement inside `while` loop raises an exception at last iteration

Do not worry if you don't understand the code or don't get context of the code, its just a solution of one of the problem statements on HackerRank 30 days of code challenge which you might want to [check](https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem)
The important part here is, that I used an infinite while loop to accept input which gave me a runtime error.

###How to tackle EOFError
We can catch EOFError as any other error, by using try-except blocks as shown below :

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try:&lt;br&gt;
    input("Please enter something")&lt;br&gt;
except:&lt;br&gt;
    print("EOF")&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You might want to do something else instead of just printing "EOF" on the console such as:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;n=int(input())&lt;br&gt;
if(n&amp;gt;=1 and n&amp;lt;=10**5):&lt;br&gt;
    phone_book={}&lt;br&gt;
    for i in range(n):&lt;br&gt;
        feed=input()&lt;br&gt;
        phone_book[feed.split()[0]]=feed.split()[1]&lt;br&gt;
    while True:&lt;br&gt;
        try:&lt;br&gt;
            name=input()&lt;br&gt;
        except EOFError:&lt;br&gt;
            break&lt;br&gt;
        if name in phone_book.keys():&lt;br&gt;
            print(name,end="")&lt;br&gt;
            print("=",end="")&lt;br&gt;
            print(phone_book[name])&lt;br&gt;
        else:&lt;br&gt;
            print("Not found")&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In the code above, python exits out of the loop if it encounters EOFError and we pass our test case, the problem due to which this discussion began...
![image](https://dev-to-uploads.s3.amazonaws.com/i/nmlt8x65v42bl926l5a4.png)

Hope this is helpful
If you know any other cases where we can expect EOFError, you might consider commenting them below.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>challenge</category>
      <category>programming</category>
    </item>
    <item>
      <title>#30DaysofFlutter</title>
      <dc:creator>Raj Pansuriya</dc:creator>
      <pubDate>Tue, 02 Feb 2021 14:28:24 +0000</pubDate>
      <link>https://dev.to/rajpansuriya/30daysofflutter-117g</link>
      <guid>https://dev.to/rajpansuriya/30daysofflutter-117g</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;First things First: What is Flutter&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Flutter is Google’s open source UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. It’s one of the fastest growing, most in-demand cross platform frameworks to learn and is used by freelance developers and large organizations around the world.&lt;/p&gt;

&lt;p&gt;In Flutter everything is a Widget. So you build your App with existing Widgets and build new ones. You can use existing Widgets and build new Widgets. You can think of it as jig-saw puzzle, where you put together several pieces (Widgets) to complete the puzzle (application).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;30 Days of flutter&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;#30DaysOfFlutter&lt;/em&gt; is an open for all initiative by Flutter Community to help developers who have experience in building apps using different SDKs and technology and aspiring app developers learn more about building apps using Flutter.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Day 1&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the &lt;a href="https://www.youtube.com/watch?v=-feG_q_0j3Y"&gt;orientation session,&lt;/a&gt; We spent some time to appreciate efforts of Flutter-Community for flutter's journey from being just an open-source project to becoming one of the most liked and preferred platform by developers.&lt;br&gt;
Here are some glimpse...&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KQK13EyW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kwesmjji93n1d6gc98zc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KQK13EyW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kwesmjji93n1d6gc98zc.png" alt="Screenshot from 2021-02-01 22-37-16" width="880" height="495"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OKVA9Aul--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fbueiqx9a10bxv3k3um0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OKVA9Aul--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fbueiqx9a10bxv3k3um0.png" alt="Screenshot from 2021-02-01 23-02-05" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we had a thorough walk-through about the &lt;a href="https://events.withgoogle.com/30-daysofflutter/content-resources/#content"&gt;resources&lt;/a&gt; we will be using and to get along with the flutter environment followed by live installation of Flutter&lt;/p&gt;

&lt;p&gt;As we went through the session we also got to know, various ways to interact  with the &lt;a href="https://flutter.dev/community"&gt;Community&lt;/a&gt; and to even contribute to the flutter project by making our own widgets and also various other ways of contribution.&lt;/p&gt;

&lt;p&gt;If you have still not registered for the #30DaysofFlutter challenge, you still have a chance to &lt;a href="https://events.withgoogle.com/30-daysofflutter/#content"&gt;register.&lt;/a&gt;&lt;br&gt;
Spare some time and visit &lt;a href="https://flutter.dev/community"&gt;Flutter-community website,&lt;/a&gt; get connected to become part of such an amazing open-source community!!&lt;/p&gt;

&lt;p&gt;I hope this article will help you understanding more about Flutter and its wonderful Community.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>beginners</category>
      <category>challenge</category>
      <category>30daysofflutter</category>
    </item>
  </channel>
</rss>
