<?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: vimala jeyakumar</title>
    <description>The latest articles on DEV Community by vimala jeyakumar (@vimala_jeyakumar_de64a9b2).</description>
    <link>https://dev.to/vimala_jeyakumar_de64a9b2</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%2F2597563%2F7749775f-2ce6-47fb-829b-25b4b9cddf0e.jpg</url>
      <title>DEV Community: vimala jeyakumar</title>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vimala_jeyakumar_de64a9b2"/>
    <language>en</language>
    <item>
      <title>Searching in java</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Tue, 25 Feb 2025 04:45:33 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/searching-in-java-9o0</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/searching-in-java-9o0</guid>
      <description>&lt;h2&gt;
  
  
  Searching:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;Searching Algorithms are designed to check for an element or retrieve an element from any data structure where it is stored.&lt;br&gt;
--&amp;gt;In Java,searching refers to the process of finding an element in a data structure like an array,list,or map. &lt;br&gt;
--&amp;gt; Based on the type of search operation, these algorithms are generally classified into two categories.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Linear Search&lt;/strong&gt;(Sequential Search)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binary Search&lt;/strong&gt;(Interval Search)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Linear Search:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt; Linear search is a fundamental search algorithm that iterates through a list of elements one by one, comparing each element to the target value.&lt;br&gt;
--&amp;gt; If the target value is found, the search stops and returns the index of the element.&lt;br&gt;
--&amp;gt; Otherwise, the search continues until the end of the list is reached, at which point it returns -1 to indicate that the target value was not found.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is Linear Search Useful?&lt;/strong&gt;&lt;br&gt;
    Linear search is useful in several scenarios:&lt;br&gt;
&lt;strong&gt;1. Small Data Sets&lt;/strong&gt;&lt;br&gt;
---&amp;gt;When the data set is relatively small (e.g., less than a few     hundred elements), linear search can be efficient because the number of comparisons required is small.&lt;br&gt;
&lt;strong&gt;2. Unsorted Data&lt;/strong&gt;&lt;br&gt;
  --&amp;gt;Linear search is particularly useful for unsorted data, as it    does not require any prior sorting of the elements.&lt;br&gt;
&lt;strong&gt;3. Simple Implementation&lt;/strong&gt;&lt;br&gt;
   --&amp;gt;Linear search is one of the simplest search algorithms to implement, making it suitable for beginners and educational purposes.&lt;br&gt;
&lt;strong&gt;4. Iterative Nature&lt;/strong&gt;&lt;br&gt;
  --&amp;gt;Linear search is an iterative algorithm, meaning it can be easily implemented using a loop. This makes it easy to understand and debug.&lt;br&gt;
&lt;strong&gt;5. Real-Time Applications&lt;/strong&gt;&lt;br&gt;
  --&amp;gt;In certain real-time applications where the data set is constantly changing, linear search can be more efficient than other search algorithms that require preprocessing or sorting.&lt;br&gt;
&lt;strong&gt;6. Limited Memory&lt;/strong&gt;&lt;br&gt;
  --&amp;gt;Linear search requires minimal memory overhead, as it only needs to store the current element being compared. This makes it suitable for systems with limited memory resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example Program:(using while loop)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Search;

public class LinearSearch {

    public static void main(String[] args)
    {
    int[] arr= {12,34,76,56,87,45,100};
    int key=87;
    int i =0;
    while(true)
    {
        if (arr[i]==key)
        {
          System.out.println("key "+key+" is presenting at:"+i );
          return;// Exits the main() method immediately
         }
    i++;
    }
System.out.println("Key " + key + " is not found in the array.");
    }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
key 87 is presenting at:4&lt;/p&gt;

&lt;h2&gt;
  
  
  2.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Search;
public class LinearSearch {
    public static void main(String[] args) {
        int[] arr = {12, 34, 76, 56, 87, 45, 100};
        int key = 87;
        int i = 0;

        while (i &amp;lt; arr.length) {
            if (arr[i] == key) {
                System.out.println("Key " + key + " is present at index: " + i);
                break;// Exits only the loop, but the program continues

            }
            i++;
        }
System.out.println("Search operation complete.");

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Key 87 is present at index: 4&lt;br&gt;
Search operation complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  Note:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why Use return; Instead of break;?&lt;/strong&gt;&lt;br&gt;
--&amp;gt;&lt;strong&gt;return;&lt;/strong&gt; exits the entire method (main() in this case).&lt;br&gt;
--&amp;gt;&lt;strong&gt;break;&lt;/strong&gt; only exits the loop, but execution would continue with any remaining statements after the loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recursive Approach:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Search;

public class RecursiveLinearSearch 
{
     public static void main(String[] args) {
            int[] arr = {12, 34, 76, 56, 87, 45, 100};
            int key = 100;

            int result = linearSearch(arr, key, 0);

            if (result != -1) {
                System.out.println("Key " + key + " is present at index: " + result);
            } else {
                System.out.println("Key " + key + " is not found in the array.");
            }
        }

            public static int linearSearch(int[] arr, int key, int index) 
            {          
                if (index &amp;gt;= arr.length) 
                {
                    return -1;
                }
                if (arr[index] == key) 
                {
                    return index;
                }

                return linearSearch(arr, key, index + 1);
            }

    }



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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Key 100 is present at index: 6&lt;/p&gt;

</description>
      <category>java</category>
      <category>searching</category>
      <category>learning</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Count of digits and Palindrome</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Tue, 25 Feb 2025 02:10:50 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/count-of-digits-and-palindrome-4ie3</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/count-of-digits-and-palindrome-4ie3</guid>
      <description>&lt;h2&gt;
  
  
  Count of Digits:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;Given a number n, the task is to return the count of digits in this number.&lt;br&gt;
Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: n = 1567
Output: 4
Explanation: There are 4 digits in 1567, which are 1, 5, 6 and 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;--&amp;gt;The idea is to count the digits by removing the digits from the input number starting from right(least significant digit) to left(most significant digit) till the number is reduced to 0.&lt;br&gt;
--&amp;gt; We are removing digits from the right because the rightmost digit can be removed simply by performing integer division by 10. For eg: n = 1567, then 1567 / 10 = 156.7 = 156(Integer Division).&lt;/p&gt;

&lt;h2&gt;
  
  
  Flowchart:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fdmx7tbypfbrxqshqm79a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fdmx7tbypfbrxqshqm79a.png" alt="Image description" width="668" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package programs;

public class CountOfDigit {

    public static void main(String[] args) 
    {
        int no = 54321;
        int count = 0;
        while(no&amp;gt;0)
        {
            //System.out.println(no%10);
            //no = no/10;
            count = count+1;

        }
        System.out.println("count: "+count);

    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
5&lt;br&gt;
count: 5&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>learning</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>For loop-Numbers pattern printing</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Fri, 14 Feb 2025 03:19:48 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/for-loop-numbers-pattern-printing-54f2</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/for-loop-numbers-pattern-printing-54f2</guid>
      <description>&lt;h2&gt;
  
  
  Example Program1:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class Pattern {

    public static void main(String[] args)
    {
        pattern();
        pattern1();
        pattern2();
        pattern3();
        pattern4();
        pattern5();
        pattern6();

    }

    private static void pattern6()
    {
        for (int line=1;line&amp;lt;=9;line++)
        {
            for(int col=1;col&amp;lt;=9;col++)
            {
                if((line==9&amp;amp;&amp;amp;col&amp;lt;9)||(line==5&amp;amp;&amp;amp;col&amp;lt;9)||(line==1&amp;amp;&amp;amp;col&amp;gt;1))
                    System.out.print("* ");
                else if(col==1&amp;amp;&amp;amp;line&amp;gt;1)
                    System.out.print("* ");
                else if((line==6||line==7||line==8)&amp;amp;&amp;amp;col==9)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
         System.out.println();
        }   

    }

    private static void pattern5() 
    {
        for (int line=1;line&amp;lt;=9;line++)
        {
            for(int col=1;col&amp;lt;=9;col++)
            {
                if((line==9&amp;amp;&amp;amp;col&amp;lt;9)||(line==5&amp;amp;&amp;amp;col&amp;lt;9)||(line==1&amp;amp;&amp;amp;col&amp;gt;1))
                    System.out.print("* ");
                else if((line==2||line==3||line==4)&amp;amp;&amp;amp;col==1)
                    System.out.print("* ");
                else if((line==6||line==7||line==8)&amp;amp;&amp;amp;col==9)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
         System.out.println();
        }   

    }

    private static void pattern4() 
    {
        for (int line=1;line&amp;lt;=9;line++)
        {
            for(int col=1;col&amp;lt;=9;col++)
            {
                if((line==5&amp;amp;&amp;amp;col&amp;lt;8)||col==5||col+line==6)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
         System.out.println();
        }


    }

    private static void pattern3() 
    {
        for (int line=1;line&amp;lt;=9;line++)
        {
            for(int col=1;col&amp;lt;=9;col++)
            {
                if(line==9||line==1||(line==5)||col==9)
                    System.out.print("* ");

                else
                    System.out.print("  ");
            }
          System.out.println(); 
        }

    }

    private static void pattern2()
    {
        for (int line=1;line&amp;lt;=9;line++)
        {
            for(int col=1;col&amp;lt;=9;col++)
            {
                if((line==9&amp;amp;&amp;amp;col&amp;gt;1)||(line==5&amp;amp;&amp;amp;col&amp;gt;1)||(line==1&amp;amp;&amp;amp;col&amp;lt;9))
                    System.out.print("* ");
                else if((line==2||line==3||line==4)&amp;amp;&amp;amp;col==9)
                    System.out.print("* ");
                else if((line==6||line==7||line==8)&amp;amp;&amp;amp;col==1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
         System.out.println();
        }

    }

    private static void pattern1() 
    {
        for (int line=1;line&amp;lt;=9;line++)
        {
            for(int col=1;col&amp;lt;=9;col++)
            {
                if(line==9||col==5||col+line==6)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
         System.out.println();
        }

    }

    private static void pattern() 
    {

        for (int line=1; line&amp;lt;=10;line++)
        {
            for(int col=1; col&amp;lt;=10; col++) {
              System.out.print("*  ");  
            }

            System.out.println("  "); 
        }


    }
}




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

&lt;/div&gt;



&lt;h2&gt;
  
  
  output:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  *    
*  *  *  *  *  *  *  *  *  * 

        *         
      * *         
    *   *         
  *     *         
*       *         
        *         
        *         
        *         
* * * * * * * * *

* * * * * * * *   
                * 
                * 
                * 
  * * * * * * * * 
*                 
*                 
*                 
  * * * * * * * * 

* * * * * * * * * 
                * 
                * 
                * 
* * * * * * * * * 
                * 
                * 
                * 
* * * * * * * * * 

        *         
      * *         
    *   *         
  *     *         
* * * * * * *     
        *         
        *         
        *         


  * * * * * * * * 
*                 
*                 
*                 
* * * * * * * *   
                * 
                * 
                * 
* * * * * * * * 

  * * * * * * * * 
*                 
*                 
*                 
* * * * * * * *   
*               * 
*               * 
*               * 
* * * * * * * *   

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program2:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class Shape {

    public static void main(String[] args)
    {
        shape1();
        shape2();
        shape3();
        shape4();
    }
    private static void shape4()
    {
        for (int row = 5; row&amp;gt;=1;row--)
        {
          for(int col=1; col&amp;lt;=row; col++)
          {
             System.out.print(row+" ");
          }
        System.out.println();
    }   

    }
    private static void shape3()
    {
        for (int row=1; row&amp;lt;=5;row++)
        {
          for(int col=1; col&amp;lt;=row; col++)
          {
             System.out.print(col+" " );
          }
        System.out.println();
        }   

    }
    private static void shape2()
    {
        for (int row=1; row&amp;lt;=5;row++)
        {
          for(int col=1; col&amp;lt;=row; col++)
          {
             System.out.print("* ");
          }
        System.out.println();
        }

    }
    private static void shape1() 
    {   
      for (int row = 5; row&amp;gt;=1;row--)
        {
          for(int col=1; col&amp;lt;=row; col++)
          {
             System.out.print("* ");
          }
        System.out.println();
    }

    }
    }



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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * * * 
* * * * 
* * * 
* * 
* 

* 
* * 
* * * 
* * * * 
* * * * * 

1 
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 

5 5 5 5 5 
4 4 4 4 
3 3 3 
2 2 
1 

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

&lt;/div&gt;



</description>
      <category>java</category>
      <category>learning</category>
      <category>programbasics</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>For loop - Alphabet pattern printing</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Thu, 13 Feb 2025 03:01:43 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/for-loop-alphabet-pattern-printing-5eh9</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/for-loop-alphabet-pattern-printing-5eh9</guid>
      <description>&lt;h2&gt;
  
  
  Program 1:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternV
{
        public static void main(String[] args) 
        {
            patternV();

        }

        private static void patternV() 
        {
            for (int line=1; line&amp;lt;=9;line++)
            {
                for(int col=1; col&amp;lt;=9; col++) 
                {
                    if((line==col || line+col==10) &amp;amp;&amp;amp; line&amp;lt;=5)
                         System.out.print("* ");
                    else
                        System.out.print("  ");
                }

                System.out.println();  
            }

        }
    }


------------------------------------------------------------------
OUTPUT:

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 2:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternI 
{

    public static void main(String[] args) 
    {
        patterni();

    }

    private static void patterni()
    {
        for (int line=1; line&amp;lt;=9;line++)
        {
            for(int col=1; col&amp;lt;=9; col++) 
            {
                if (line==1 || col==5 || line==9)
                     System.out.print("* ");
                else 
                    System.out.print("  ");
            }

            System.out.println(); 
        }
    }

}

--------------------------------------------------------------------
OUTPUT:

* * * * * * * * * 
        *         
        *         
        *         
        *         
        *         
        *         
        *         
* * * * * * * * * 

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 3:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternM 
{

    public static void main(String[] args) 
    {
        patternM();


    }
    private static void patternM()
    {

        int line;
        for ( line=1; line&amp;lt;=9;line++)
        {
            for (int col=1; col&amp;lt;=9;col++)
            {
                if (col==1 || col==9)
                  System.out.print("* ");   
                else if((line==col || line+col==10)&amp;amp;&amp;amp;line&amp;lt;=5)
                       System.out.print("* ");
                 else
                     System.out.print("  ");
                }

            System.out.println(); 
        }

    }

    }


--------------------------------------------------------------------
OUTPUT:

*               * 
* *           * * 
*   *       *   * 
*     *   *     * 
*       *       * 
*               * 
*               * 
*               * 
*               * 

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 4:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternA
{

    public static void main(String[] args) 
    {
        patternA();

    }

    private static void patternA() 
    {
        for (int line=1; line&amp;lt;=9;line++)
        {
            for(int col=1; col&amp;lt;=9; col++) 
            {
                if((line==col || line+col==10) &amp;amp;&amp;amp; 5&amp;lt;=line)
                     System.out.print("* ");
                else if( (line==7 ||col==3||col==4|| col==5)&amp;amp;&amp;amp; 7==line)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }

            System.out.println();  
        }

    }

}
--------------------------------------------------------------------
OUTPUT:

        *         
      *   *       
* * * * * * * * * 
  *           *   
*               * 

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 5:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternL
{

    public static void main(String[] args) 
    {
        patternL();

    }

    private static void patternL() 
    {
        int line;
        for ( line=1; line&amp;lt;=9;line++)
        {
            for (int col=1; col&amp;lt;=9;col++)
            {
                if (col==1 || line==9)
                  System.out.print("* ");   
                 else
                     System.out.print("  ");
                }

            System.out.println(); 
        }
    }

}
--------------------------------------------------------------------
OUTPUT:

*                 
*                 
*                 
*                 
*                 
*                 
*                 
*                 
* * * * * * * * * 

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 6:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternD {

    public static void main(String[] args) 
    {
        patternD();
    }

    private static void patternD()
    {   
        for (int line=1; line&amp;lt;=10;line++)
            {
               for(int col=1; col&amp;lt;=10; col++) 
                 {
                    if(col==3||col==10)
                          System.out.print("* "); 
                    else if(line==10 || line==1)
                           System.out.print("* ");
                     else
                         System.out.print("  ");
            }

                        System.out.println(" "); 
                    }

    }

}
--------------------------------------------------------------------
OUTPUT:

* * * * * * * * * *  
    *             *  
    *             *  
    *             *  
    *             *  
    *             *  
    *             *  
    *             *  
    *             *  
* * * * * * * * * *  

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 7:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternE {

    public static void main(String[] args) 
    {
            patternE();
            patternV();
            patterni();

    }

    private static void patterni()
    {
        for (int line=1; line&amp;lt;=9;line++)
        {
            for(int col=1; col&amp;lt;=9; col++) 
            {
                if (line==1 || col==5 || line==9)
                     System.out.print("* ");
                else 
                    System.out.print("  ");
            }

            System.out.println(); 
        }
    }

    private static void patternV() 
    {
        for (int line=1; line&amp;lt;=9;line++)
        {
            for(int col=1; col&amp;lt;=9; col++) 
            {
                if((line==col || line+col==10) &amp;amp;&amp;amp; line&amp;lt;=5)
                     System.out.print("* ");
                else
                    System.out.print("  ");
            }

            System.out.println();  
        }

    }

        private static void patternE() 
        {

            for (int line=1; line&amp;lt;=10;line++)
            {
                for(int col=1; col&amp;lt;=10; col++) 
                {
                    if(line==1||col==1||line==10||line==5)
                  System.out.print("* ");  
                }

                System.out.println("  "); 
            }


    }

}

--------------------------------------------------------------------
OUTPUT:

* * * * * * * * * *   
*   
*   
*   
* * * * * * * * * *   
*   
*   
*   
*   
* * * * * * * * * *


*               * 
  *           *   
    *       *     
      *   *       
        *       


* * * * * * * * * 
        *         
        *         
        *         
        *         
        *         
        *         
        *         
* * * * * * * * * 


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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 8:(F)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class PatternF {

    public static void main(String[] args) 
    {
        patternF();

    }

    private static void patternF() 
    {

        for (int line=1; line&amp;lt;=10;line++)
        {
            for(int col=1; col&amp;lt;=5; col++) 
            {
                if(line==1||col==1||line==5)
              System.out.print("* ");  
            }

            System.out.println("  "); 
        }
    }
    }

--------------------------------------------------------------------
OUTPUT:

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 9:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class Pattern1
{

    public static void main(String[] args) 
    {
        pattern1();
        pattern2();

    }

    private static void pattern2() 
    {
        for (int line=1; line&amp;lt;=10;line++)
        {
           for(int col=1; col&amp;lt;=10; col++) 
             {
                if(col==1||col==10)
                      System.out.print("* "); 
                else if(line==col||line+col==10)
                       System.out.print("* ");
                 else
                     System.out.print("  ");
               }

           System.out.println("  ");     
}}


    private static void pattern1()
    {
        for (int line=1; line&amp;lt;=10;line++)
        {
           for(int col=1; col&amp;lt;=10; col++) 
             {
                if(col==1||col==10)
                      System.out.print("* "); 
                else if(line==10 || line==1||line==col||line+col==10)
                       System.out.print("* ");
                 else
                     System.out.print("  ");
               }

           System.out.println("  ");     
}}

}


--------------------------------------------------------------------
OUTPUT:

* * * * * * * * * *   
* *           *   *   
*   *       *     *   
*     *   *       *   
*       *         *   
*     *   *       *   
*   *       *     *   
* *           *   *   
*               * *   
* * * * * * * * * * 


*               * *   
* *           *   *   
*   *       *     *   
*     *   *       *   
*       *         *   
*     *   *       *   
*   *       *     *   
* *           *   *   
*               * *   
*                 *   

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Program 10:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Forloop;

public class Pattern2 {

    public static void main(String[] args) 
    {
        pattern2();

    }

    private static void pattern2() 
    {
            for (int line=1; line&amp;lt;=10;line++)
            {
               for(int col=1; col&amp;lt;=10; col++) 
                 {
                    if(col==5||line==5)
                          System.out.print("* "); 
                    else if(line==col||line+col==10)
                           System.out.print("* ");
                     else
                         System.out.print("  ");
                   }

               System.out.println("  ");     
    }}

    }


--------------------------------------------------------------------
OUTPUT:

*       *       *     
  *     *     *       
    *   *   *         
      * * *           
* * * * * * * * * *   
      * * *           
    *   *   *         
  *     *     *       
*       *       *     
        *         *   

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

&lt;/div&gt;



</description>
      <category>java</category>
      <category>programs</category>
      <category>learning</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Modulo or Remainder in java</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Wed, 12 Feb 2025 14:43:50 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/modulo-or-reminder-in-java-18m1</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/modulo-or-reminder-in-java-18m1</guid>
      <description>&lt;h2&gt;
  
  
  Remainder:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;Modulo or Remainder Operator returns the remainder of the two numbers after division. &lt;br&gt;
--&amp;gt;If you are provided with two numbers, say A and B, A is the dividend and B is the divisor, A mod B is there a remainder of the division of A and B. &lt;br&gt;
--&amp;gt;Modulo operator is an arithmetical operator which is denoted by %.&lt;br&gt;
&lt;strong&gt;NOTE:&lt;/strong&gt;&lt;br&gt;
   If numerator is less than denominator then % will give output as the numerator only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A % B
Where A is the dividend and B is divisor

quotient = dividend / divisor;
remainder = dividend % divisor;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Quotient:
&lt;/h2&gt;

&lt;p&gt;The quotient is the quantity produced by the division of two numbers. For example,&lt;br&gt;
--&amp;gt;(7/2) = 3 In the above expression 7 is divided by 2, so the quotient is 3 and the remainder is 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Program:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package programs;

public class Reminder {

    public static void main(String[] args) 
    {
        int no = 6547;

        while(no&amp;gt;0)
        {
            System.out.println(no%10);// 5 4 3 2

            no=no/10;//123 12 1
        }

    }

}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
7&lt;br&gt;
4&lt;br&gt;
5&lt;br&gt;
6&lt;br&gt;
&lt;strong&gt;example program:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package programs;

public class Reminder {

    public static void main(String[] args) 
    {
        int no = 6547;
        int reminder;
        int quotient;
        while(no&amp;gt;0){

            reminder=no%10;// 5 4 3 2
            System.out.println("Reminder: "+reminder);
            quotient=no/10;//123 12 1
            System.out.println("Quotient: "+quotient);
            no=quotient;
        }


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Reminder: 7&lt;br&gt;
Quotient: 654&lt;br&gt;
Reminder: 4&lt;br&gt;
Quotient: 65&lt;br&gt;
Reminder: 5&lt;br&gt;
Quotient: 6&lt;br&gt;
Reminder: 6&lt;br&gt;
Quotient: 0&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/program-to-find-quotient-and-remainder-in-java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/program-to-find-quotient-and-remainder-in-java/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/modulo-or-remainder-operator-in-java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/modulo-or-remainder-operator-in-java/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.tpointtech.com/write-a-program-to-find-the-quotient-and-remainder" rel="noopener noreferrer"&gt;https://www.tpointtech.com/write-a-program-to-find-the-quotient-and-remainder&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>program</category>
      <category>basic</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Reverse in java</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Tue, 11 Feb 2025 17:32:46 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/reverse-in-java-49fp</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/reverse-in-java-49fp</guid>
      <description>&lt;h2&gt;
  
  
  Definition:
&lt;/h2&gt;

&lt;p&gt;-&amp;gt;In Java, "reverse" refers to the process of changing the order of elements in a data structure so that they appear in the opposite sequence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Strings&lt;/strong&gt; – Changing the order of characters (e.g., "hello" → "olleh").&lt;br&gt;
&lt;strong&gt;2.Arrays&lt;/strong&gt; – Changing the order of elements in an array &lt;br&gt;
      (e.g., {1,      2, 3} → {3, 2, 1}).&lt;br&gt;
&lt;strong&gt;3.Lists&lt;/strong&gt;  – Reversing the order of elements in an ArrayList,       LinkedList, etc.&lt;br&gt;
&lt;strong&gt;4.Numbers&lt;/strong&gt; – Reversing the digits of an integer (e.g., 123 → 321).&lt;/p&gt;
&lt;h2&gt;
  
  
  Reverse Number:
&lt;/h2&gt;

&lt;p&gt;-&amp;gt;In Java, reversing a number means that the digit at the first position should be swapped with the last digit, the second digit will be swapped with the second last digit, and so on till the middle element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm for Reversing a Number in Java&lt;/strong&gt;&lt;br&gt;
   -&amp;gt;Take the number’s modulo by 10.&lt;br&gt;
   -&amp;gt;Multiply the reverse number by 10 and add modulo value into the reverse number.&lt;br&gt;
   -&amp;gt;Divide the number by 10.&lt;br&gt;
   -&amp;gt;Repeat above steps until number becomes zero.&lt;br&gt;
&lt;strong&gt;Example Program:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package programs;

public class Reverse 
{

    public static void main(String[] args) 
    {
                int num = 2910;
                int reversed = 0;

                while (num != 0) 
                {
                    int digit = num % 10;
                    reversed = reversed * 10 + digit;
                    num /= 10;
                    System.out.println("Reversed: " + reversed);
                }
//              System.out.println("Reversed: " + reversed);
            }       
    }



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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output:&lt;/strong&gt;&lt;br&gt;
Reversed: 0&lt;br&gt;
Reversed: 1&lt;br&gt;
Reversed: 19&lt;br&gt;
Reversed: 192&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reverse String:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package programs;

public class ReverseString {

    public static void main(String[] args) 
    {
        String str = "Hello";
        String reversed = "";
        for (int i = str.length() - 1; i &amp;gt;= 0; i--) {
            reversed += str.charAt(i);
        }
        System.out.println("Reversed: " + reversed);

    }

}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output:&lt;/strong&gt;&lt;br&gt;
Reversed: olleH&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;br&gt;
--&amp;gt; &lt;a href="https://www.geeksforgeeks.org/java-reverse-number-program/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/java-reverse-number-program/&lt;/a&gt;&lt;br&gt;
--&amp;gt; &lt;a href="https://www.tpointtech.com/how-to-reverse-string-in-java" rel="noopener noreferrer"&gt;https://www.tpointtech.com/how-to-reverse-string-in-java&lt;/a&gt;&lt;br&gt;
--&amp;gt; &lt;a href="https://chatgpt.com/c/67ab758b-6c98-800f-8b8f-b39e0d01b060" rel="noopener noreferrer"&gt;https://chatgpt.com/c/67ab758b-6c98-800f-8b8f-b39e0d01b060&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>learning</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Number Series</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Mon, 03 Feb 2025 13:54:19 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/number-series-aj0</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/number-series-aj0</guid>
      <description>&lt;h2&gt;
  
  
  Task:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1 . Look at this series: 58, 52, 46, 40, 34, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
26&lt;/p&gt;

&lt;p&gt;28&lt;/p&gt;

&lt;p&gt;30&lt;/p&gt;

&lt;p&gt;32&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
The series is decreasing by 6 each time:&lt;/p&gt;

&lt;p&gt;58 - 6 = 52&lt;br&gt;
52 - 6 = 46&lt;br&gt;
46 - 6 = 40&lt;br&gt;
40 - 6 = 34&lt;/p&gt;

&lt;p&gt;So, continuing the pattern, 34 - 6 = 28.&lt;/p&gt;

&lt;p&gt;The next number in the series is 28.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries1 
{
public static void main (String args[])
{
    int no = 58;
    int count = 1;
    while( count&amp;lt;=5)
    {
        System.out.println(no);
        no = no-6;
        count = count+ 1;

    }
}
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output:&lt;/strong&gt;&lt;br&gt;
58&lt;br&gt;
52&lt;br&gt;
46&lt;br&gt;
40&lt;br&gt;
34&lt;br&gt;
28&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.Look at this series: 3, 4, 7, 8, 11, 12, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
7&lt;/p&gt;

&lt;p&gt;10&lt;/p&gt;

&lt;p&gt;14&lt;/p&gt;

&lt;p&gt;15&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
Let’s look at the pattern:&lt;/p&gt;

&lt;p&gt;3 → 4 (add 1)&lt;br&gt;
4 → 7 (add 3)&lt;br&gt;
7 → 8 (add 1)&lt;br&gt;
8 → 11 (add 3)&lt;br&gt;
11 → 12 (add 1)&lt;/p&gt;

&lt;p&gt;It looks like the pattern alternates between adding 1 and adding 3.&lt;/p&gt;

&lt;p&gt;Following this pattern, the next step is to add 3 to 12, so:&lt;/p&gt;

&lt;p&gt;12 + 3 = 15&lt;/p&gt;

&lt;p&gt;The next number in the series is 15.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries2 {

    public static void main(String[] args) {
        int no = 3;
        int count =1;
        while( count&amp;lt;=7)
        {
            System.out.println(no);
            no = no+1;
            System.out.println(no);
            no = no+3;
            count = count+2;
        }
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output:&lt;/strong&gt;&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
7&lt;br&gt;
8&lt;br&gt;
11&lt;br&gt;
12&lt;br&gt;
15&lt;br&gt;
16&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Look at this series: 31, 29, 24, 22, 17, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
15&lt;/p&gt;

&lt;p&gt;14&lt;/p&gt;

&lt;p&gt;13&lt;/p&gt;

&lt;p&gt;12&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
Let’s examine the pattern:&lt;/p&gt;

&lt;p&gt;31 → 29 (subtract 2)&lt;br&gt;
29 → 24 (subtract 5)&lt;br&gt;
24 → 22 (subtract 2)&lt;br&gt;
22 → 17 (subtract 5)&lt;/p&gt;

&lt;p&gt;The pattern alternates between subtracting 2 and subtracting 5.&lt;/p&gt;

&lt;p&gt;So, following this pattern, the next step is to subtract 2 from 17:&lt;/p&gt;

&lt;p&gt;17 - 2 = 15&lt;/p&gt;

&lt;p&gt;The next number in the series is 15.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries3 {

    public static void main(String[] args) 
    {

        int no = 31;
        int count =0;
        while( count&amp;lt;=5)
        {
            System.out.println(no);
            no = no-2;
            System.out.println(no);
            no = no-5;
            count = count+2;
        }


    }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output:&lt;/strong&gt;&lt;br&gt;
31&lt;br&gt;
29&lt;br&gt;
24&lt;br&gt;
22&lt;br&gt;
17&lt;br&gt;
15&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.Look at this series: 1.5, 2.3, 3.1, 3.9, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
4.2&lt;/p&gt;

&lt;p&gt;4.4&lt;/p&gt;

&lt;p&gt;4.7&lt;/p&gt;

&lt;p&gt;5.1&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
Let’s examine the differences between the numbers in the series:&lt;/p&gt;

&lt;p&gt;2.3 - 1.5 = 0.8&lt;br&gt;
3.1 - 2.3 = 0.8&lt;br&gt;
3.9 - 3.1 = 0.8&lt;/p&gt;

&lt;p&gt;It looks like the series increases by 0.8 each time. So, to find the next number:&lt;/p&gt;

&lt;p&gt;3.9 + 0.8 = 4.7&lt;/p&gt;

&lt;p&gt;The next number in the series is 4.7.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries4 {

    public static void main(String[] args)
    {
        float no = 1.5f;
        int count  = 1;
        while (count&amp;lt;6)
        {
            System.out.println(no);
             no = no + 0.8f; 
             count = count+1;
        }
    }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
1.5&lt;br&gt;
2.3&lt;br&gt;
3.1&lt;br&gt;
3.8999999&lt;br&gt;
4.7&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.Look at this series: 201, 202, 204, 207, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
205&lt;/p&gt;

&lt;p&gt;208&lt;/p&gt;

&lt;p&gt;210&lt;/p&gt;

&lt;p&gt;211&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
Let’s look at the differences between the numbers:&lt;/p&gt;

&lt;p&gt;202 - 201 = 1&lt;br&gt;
204 - 202 = 2&lt;br&gt;
207 - 204 = 3&lt;/p&gt;

&lt;p&gt;It seems the series is increasing by 1, 2, 3, and so on.&lt;/p&gt;

&lt;p&gt;Following this pattern, the next difference should be 4. So:&lt;/p&gt;

&lt;p&gt;207 + 4 = 211&lt;/p&gt;

&lt;p&gt;The next number in the series is 211.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries5 
{
    public static void main(String[] args)
    {
        int no = 201;
        int count = 1;
        while( count&amp;lt;6)
        {
            System.out.println(no);
            no = no+1;
            System.out.println(no);
            no = no+2;
            System.out.println(no);
            no=no+3;
            System.out.println(no);
            no=no+4;
            count = count+4;
        }
    }

}


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
204&lt;br&gt;
207&lt;br&gt;
211&lt;br&gt;
212&lt;br&gt;
214&lt;br&gt;
217&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.Look at this series: 2, 6, 18, 54, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
108&lt;/p&gt;

&lt;p&gt;148&lt;/p&gt;

&lt;p&gt;162&lt;/p&gt;

&lt;p&gt;216&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
The pattern in the series appears to be multiplying each term by 3:&lt;/p&gt;

&lt;p&gt;2 × 3 = 6&lt;br&gt;
 6 × 3 = 18&lt;br&gt;
 18 × 3 = 54&lt;/p&gt;

&lt;p&gt;So, to find the next number, we multiply 54 by 3:&lt;/p&gt;

&lt;p&gt;54 × 3 = 162&lt;/p&gt;

&lt;p&gt;Thus, the next number in the series is 162.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries6 
{
    public static void main(String[] args)
    {
        int no =2;
        int count = 1;
        while( count&amp;lt;6)
        {
            System.out.println(no);
            no = no*3;
            count = count+1;
        }

}
    }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
2&lt;br&gt;
6&lt;br&gt;
18&lt;br&gt;
54&lt;br&gt;
162&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7.Look at this series: 5.2, 4.8, 4.4, 4, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
3&lt;/p&gt;

&lt;p&gt;3.3&lt;/p&gt;

&lt;p&gt;3.5&lt;/p&gt;

&lt;p&gt;3.6&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
The pattern in this series appears to be decreasing by 0.4 each time:&lt;/p&gt;

&lt;p&gt;5.2 - 0.4 = 4.8&lt;br&gt;
  4.8 - 0.4 = 4.4&lt;br&gt;
  4.4 - 0.4 = 4&lt;/p&gt;

&lt;p&gt;So, to find the next number, we subtract 0.4 from 4:&lt;/p&gt;

&lt;p&gt;4 - 0.4 = 3.6&lt;/p&gt;

&lt;p&gt;Thus, the next number in the series is 3.6.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries7
{
    public static void main(String[] args)
    {
        float no =5.2f;
        int count = 1;
        while( count&amp;lt;6)
        {
            System.out.println(no);
            no = no-0.4f;
            count = count+1;
        }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
5.2&lt;br&gt;
4.7999997&lt;br&gt;
4.3999996&lt;br&gt;
3.9999995&lt;br&gt;
3.5999994&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8.Look at this series: 2, 4, 6, 8, 10, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
11&lt;/p&gt;

&lt;p&gt;12&lt;/p&gt;

&lt;p&gt;13&lt;/p&gt;

&lt;p&gt;14&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
The pattern in this series is increasing by 2 each time:&lt;/p&gt;

&lt;p&gt;2 + 2 = 4&lt;br&gt;
  4 + 2 = 6&lt;br&gt;
  6 + 2 = 8&lt;br&gt;
  8 + 2 = 10&lt;/p&gt;

&lt;p&gt;So, to find the next number, we add 2 to 10:&lt;/p&gt;

&lt;p&gt;10 + 2 = 12&lt;/p&gt;

&lt;p&gt;Thus, the next number in the series is 12.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries8 {

    public static void main(String[] args) 
    {
        int no =2;
        int count = 0;
        while( count&amp;lt;6)
        {
            System.out.println(no);
            no = no+2;
            count = count+1;
        }

    }

}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
2&lt;br&gt;
4&lt;br&gt;
6&lt;br&gt;
8&lt;br&gt;
10&lt;br&gt;
12&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9.Look at this series: 36, 34, 30, 28, 24, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
20&lt;/p&gt;

&lt;p&gt;22&lt;/p&gt;

&lt;p&gt;23&lt;/p&gt;

&lt;p&gt;26&lt;br&gt;
&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
The pattern in this series alternates between subtracting 2 and subtracting 4:&lt;/p&gt;

&lt;p&gt;36 - 2 = 34&lt;br&gt;
  34 - 4 = 30&lt;br&gt;&lt;br&gt;
  30 - 2 = 28&lt;br&gt;
  28 - 4 = 24&lt;/p&gt;

&lt;p&gt;To find the next number, we subtract 2 from 24:&lt;/p&gt;

&lt;p&gt;24 - 2 = 22&lt;/p&gt;

&lt;p&gt;Thus, the next number in the series is 22.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries9 {

    public static void main(String[] args)
    {
        int no =36;
        int count = 0;
        while( count&amp;lt;6)
        {
            System.out.println(no);
            no = no-2;
            System.out.println(no);
            no = no-4;
            count = count+2;
        }



    }

}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
36&lt;br&gt;
34&lt;br&gt;
30&lt;br&gt;
28&lt;br&gt;
24&lt;br&gt;
22&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10.Look at this series: 22, 21, 23, 22, 24, 23, ... What number should come next?&lt;/strong&gt;&lt;br&gt;
22&lt;/p&gt;

&lt;p&gt;24&lt;/p&gt;

&lt;p&gt;25&lt;/p&gt;

&lt;p&gt;26&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ans:&lt;/strong&gt;&lt;br&gt;
The pattern in this series alternates between subtracting 1 and adding 2:&lt;/p&gt;

&lt;p&gt;22 - 1 = 21&lt;br&gt;
  21 + 2 = 23&lt;br&gt;
  23 - 1 = 22&lt;br&gt;
  22 + 2 = 24&lt;br&gt;
  24 - 1 = 23&lt;/p&gt;

&lt;p&gt;So, the next step should be adding 2 to 23:&lt;/p&gt;

&lt;p&gt;23 + 2 = 25&lt;/p&gt;

&lt;p&gt;Thus, the next number in the series is 25.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;

public class Numberseries10 
{

    public static void main(String[] args) 
    {
        int no =22;
        int count = 0;
        while( count&amp;lt;7)
        {
            System.out.println(no);
            no = no-1;
            System.out.println(no);
            no = no+2;
            count = count+2;
        }


    }

}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
22&lt;br&gt;
21&lt;br&gt;
23&lt;br&gt;
22&lt;br&gt;
24&lt;br&gt;
23&lt;br&gt;
25&lt;br&gt;
24&lt;/p&gt;

</description>
      <category>program</category>
      <category>java</category>
      <category>basics</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Control flow statement</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Thu, 30 Jan 2025 18:25:00 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/control-flow-statement-2p6n</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/control-flow-statement-2p6n</guid>
      <description>&lt;h2&gt;
  
  
  Control flow Statement:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;Java compiler executes the code from top to bottom. The statements in the code are executed according to the order in which they appear. &lt;br&gt;
--&amp;gt;However, Java provides statements that can be used to control the flow of Java code. Such statements are called control flow statements.&lt;br&gt;
--&amp;gt; It is one of the fundamental features of Java, which provides a smooth flow of program.&lt;br&gt;
&lt;strong&gt;Loop statement&lt;/strong&gt;&lt;br&gt;
--&amp;gt;In programming, sometimes we need to execute the block of code repeatedly while some condition evaluates to true. &lt;br&gt;
--&amp;gt;However, loop statements are used to execute the set of instructions in a repeated order. &lt;br&gt;
--&amp;gt;The execution of the set of instructions depends upon a particular condition.&lt;br&gt;
    1.do while loop&lt;br&gt;
    2.while loop&lt;br&gt;
    3.for loop&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;While loop:&lt;/strong&gt;&lt;br&gt;
--&amp;gt;The while loop is also used to iterate over the number of statements multiple times. However, if we don't know the number of iterations in advance, it is recommended to use a while loop.&lt;br&gt;
--&amp;gt;Unlike for loop, the initialization and increment/decrement doesn't take place inside the loop statement in while loop.&lt;br&gt;
--&amp;gt;Java while loop is a control flow statement used to execute the block of statements repeatedly until the given condition evaluates to false.&lt;br&gt;
--&amp;gt;Once the condition becomes false, the line immediately after the loop in the program is executed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If we do not provide the curly braces ‘{‘ and ‘}’ after while( condition ), then by default while statement will consider the immediate one statement to be inside its block.&lt;/p&gt;
&lt;h2&gt;
  
  
  Syntax:
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while (test_expression) {   

     // statements        

    update_expression; 


    }


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

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fsfu81qdkwu2iowfntejp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fsfu81qdkwu2iowfntejp.png" alt="Image description" width="339" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example program:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;
public class WhileLoop {
    public static void main(String[] args) 
    {
      int c = 1; 
     while (c &amp;lt;= 5) 
     {   
       System.out.println(c); 
         c++;  
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
5&lt;br&gt;
&lt;strong&gt;2.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;
class whileLoop {
    public static void main(String args[])
    {
        int i = 1;
      while (i &amp;lt; 6) {
            System.out.println("Welcome to java");  
           i++;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Welcome to java&lt;br&gt;
Welcome to java&lt;br&gt;
Welcome to java&lt;br&gt;
Welcome to java&lt;br&gt;
Welcome to java&lt;/p&gt;

&lt;h2&gt;
  
  
  Task1:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F8rmi4bkt6514q92iw2d3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F8rmi4bkt6514q92iw2d3.png" alt="Image description" width="372" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;program:&lt;/strong&gt;&lt;br&gt;
public class Count&lt;br&gt;
{&lt;br&gt;
public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
int count = 1;&lt;br&gt;
while(count&amp;lt;=5){&lt;br&gt;
count=count+1;&lt;br&gt;
System.out.println("count:  "+ count);&lt;br&gt;
}}}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
count:  2&lt;br&gt;
count:  3&lt;br&gt;
count:  4&lt;br&gt;
count:  5&lt;br&gt;
count:  6&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhptuz3nm13jfqyh9j1et.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhptuz3nm13jfqyh9j1et.png" alt="Image description" width="425" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Program:&lt;/strong&gt;&lt;br&gt;
public class Count1&lt;br&gt;
{&lt;br&gt;
public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
int count = 5;&lt;br&gt;
while(count&amp;gt;=1)&lt;br&gt;
{&lt;br&gt;
count=count-1;&lt;br&gt;
System.out.println("count: "+ count);&lt;br&gt;
}&lt;br&gt;
}}&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
count: 4&lt;br&gt;
count: 3&lt;br&gt;
count: 2&lt;br&gt;
count: 1&lt;br&gt;
count: 0&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4dhwks1u928kfheywpqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4dhwks1u928kfheywpqy.png" alt="Image description" width="430" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;program:&lt;/strong&gt;&lt;br&gt;
public class Count2&lt;br&gt;
{&lt;br&gt;
public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
int count = 1;&lt;br&gt;
while(count&amp;lt;=10){&lt;br&gt;
count=count+2;&lt;br&gt;
System.out.println("count:  "+ count);&lt;br&gt;
}}}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
count:  3&lt;br&gt;
count:  5&lt;br&gt;
count:  7&lt;br&gt;
count:  9&lt;br&gt;
count:  11&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 4:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fg5dba1j5grxcw7faywi6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fg5dba1j5grxcw7faywi6.png" alt="Image description" width="391" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Program:&lt;/strong&gt;&lt;br&gt;
public class Count3&lt;br&gt;
{&lt;br&gt;
public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
int count = 0;&lt;br&gt;
while(count&amp;lt;10)&lt;br&gt;
{&lt;br&gt;
count=count+2;&lt;br&gt;
System.out.println("count: "+ count);&lt;br&gt;
}&lt;br&gt;
}}&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
count: 2&lt;br&gt;
count: 4&lt;br&gt;
count: 6&lt;br&gt;
count: 8&lt;br&gt;
count: 10&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refernce:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/java/java_while_loop.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/java/java_while_loop.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.codingem.com/flowchart-loop/" rel="noopener noreferrer"&gt;https://www.codingem.com/flowchart-loop/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/java-while-loop-with-examples/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/java-while-loop-with-examples/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/control-flow-statements-in-programming/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/control-flow-statements-in-programming/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>program</category>
      <category>beginners</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Switch statement &amp; Ternary operator</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Thu, 30 Jan 2025 10:41:10 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/switch-statement-ternary-operator-2id6</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/switch-statement-ternary-operator-2id6</guid>
      <description>&lt;h2&gt;
  
  
  Switch Statement:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;The switch statement in Java is a multi-way branch statement. In simple words, the Java switch statement executes one statement from multiple conditions.&lt;br&gt;
--&amp;gt;It is an alternative to an if-else-if ladder statement. It provides an easy way to dispatch execution to different parts of code based on the value of the expression.&lt;br&gt;
--&amp;gt;The expression can be of type byte, short, char, int, long, (enums, String, or wrapper classes(TBD).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Java switch expression must be of byte, short, int, long(with its Wrapper type), enums and string. Beginning with JDK7, it also works with enumerated types (Enums in java), the String class, and Wrapper classes.&lt;/p&gt;
&lt;h2&gt;
  
  
  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 :
     // Statements
     break; // break is optional

  case value2 :
     // Statements
     break; // break is optional
     ....
     ....
     ....
   default : 
     // default Statement
}


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

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fo6j3gb0veawc9evdq1gn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fo6j3gb0veawc9evdq1gn.jpg" alt="Image description" width="702" height="971"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Example program:
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1.package day1if;
public class SizePrinter {

    public static void main(String[] args) {
        int sizeNumber = 15;

        switch (sizeNumber) {
            case 1:
                System.out.println("Extra Small");
                break;
            case 2:
                System.out.println("Small");
                break;
            case 3:
                System.out.println("Medium");
                break;
            case 4:
                System.out.println("Large");
                break;
            case 5:
                System.out.println("Extra Large");
                break;
            default:
                System.out.println("Invalid size number");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Invalid size number&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.package day1if;

public class Days{

    public static void main(String[] args)
    {
        int day =4;
        String dayString;

        switch (day) 
        { 
         case 1:
            dayString = "Monday";
            break;      
        case 2:
            dayString = "Tuesday";
            break;
        case 3:
            dayString = "Wednesday";
            break;
        case 4:
            dayString = "Thursday";
            break;
        case 5:
            dayString = "Friday";
            break;
        case 6:
            dayString = "Saturday";
            break;
        case 7:
            dayString = "Sunday";
            break;
        default:
            dayString = "Invalid day";
        }
        System.out.println(dayString);
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Thursday&lt;/p&gt;
&lt;h2&gt;
  
  
  Ternary Operator:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;The ternary operator is a shorthand way of writing an if-else statement. It takes three operands: a condition, a result for when the condition is true, and a result for when the condition is false.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Every code using an if-else statement cannot be replaced with a ternary operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;condition ? result_if_true : result_if_false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhnv8mzuwwpwoqqkg55fs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhnv8mzuwwpwoqqkg55fs.png" alt="Image description" width="634" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fa39g74ovjsjowmi4x203.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fa39g74ovjsjowmi4x203.png" alt="Image description" width="447" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example program:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;
public class TernaryOperator
{  
public static void main(String args[])   
{  
int x, y;  
x = 20;  
y = (x == 1) ? 61: 90;  
System.out.println("Value of y is: " + y);  
y = (x == 20) ? 61: 90;  
System.out.println("Value of y is: " + y);  
}  
}  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
Value of y is: 90&lt;br&gt;
Value of y is: 61&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference:
&lt;/h2&gt;

&lt;p&gt;-&amp;gt;&lt;a href="https://www.geeksforgeeks.org/switch-statement-in-java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/switch-statement-in-java/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-&amp;gt;&lt;a href="https://www.geeksforgeeks.org/conditional-statements-in-programming/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/conditional-statements-in-programming/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-&amp;gt;&lt;a href="https://www.javatpoint.com/ternary-operator-in-java" rel="noopener noreferrer"&gt;https://www.javatpoint.com/ternary-operator-in-java&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>learning</category>
      <category>beginners</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Data Structure Basics</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Thu, 30 Jan 2025 07:28:42 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/data-structure-basics-214d</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/data-structure-basics-214d</guid>
      <description>&lt;h2&gt;
  
  
  Data Structure  Basics :
&lt;/h2&gt;

&lt;p&gt;1.Normal Statement&lt;br&gt;
  2.Conditional  Statement&lt;br&gt;
  3.Control flow Statement&lt;br&gt;
&lt;strong&gt;Normal Statement:&lt;/strong&gt;&lt;br&gt;
   --&amp;gt;we declare variables and constants by specifying their data type and name. A variable holds a value that is going to use in the Java program.&lt;br&gt;
&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
int quantity = 20; &lt;br&gt;
boolean flag = false;&lt;br&gt;
String message = "Hello;&lt;/p&gt;
&lt;h2&gt;
  
  
  Conditional  Statement:
&lt;/h2&gt;

&lt;p&gt;==&amp;gt;Conditional statements in programming are used to control the flow of a program based on certain conditions. &lt;br&gt;
==&amp;gt;These statements allow the execution of different code blocks depending on whether a specified condition evaluates to true or false, providing a fundamental mechanism for decision-making in algorithms. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F7vpkel8ofo2tkeeu5bba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7vpkel8ofo2tkeeu5bba.png" alt="Image description" width="313" height="139"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  If Statement:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;The if statement is the most basic form of conditional statement. It checks if a condition is true. If it is, the program executes a block of code.&lt;br&gt;
--&amp;gt;if condition is true, the if code block executes. If false, the execution moves to the next block to check.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (condition) {
    // code to execute if condition is true
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4tp0nh6mm7ff8b700qjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4tp0nh6mm7ff8b700qjm.png" alt="Image description" width="440" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Program:&lt;/strong&gt;&lt;br&gt;
package day1if;&lt;/p&gt;

&lt;p&gt;public class Players&lt;br&gt;
{&lt;br&gt;
 public static void main(String[] args) &lt;br&gt;
  {&lt;br&gt;
    // TODO Auto-generated method stub&lt;br&gt;
       int Cricket = 11;&lt;br&gt;
       int basketball = 12;&lt;br&gt;
    if(Cricket&amp;lt;basketball)&lt;br&gt;
    {&lt;br&gt;
    System.out.println("it is true"); &lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
it is true&lt;/p&gt;
&lt;h2&gt;
  
  
  If-Else Statement:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt; The if-else statement in Java is a powerful decision-making tool used to control the program’s flow based on conditions. &lt;br&gt;
--&amp;gt;It executes one block of code if a condition is true and another block if the condition is false.&lt;br&gt;
&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (condition)
{
//Statements to be executed if condition satisfies
}
else
{
//Statements to be executed if the condition is not satisfied
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhzokb498bmirpp1nccoe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhzokb498bmirpp1nccoe.png" alt="Image description" width="190" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Program:&lt;/strong&gt;&lt;br&gt;
package day1if;&lt;/p&gt;

&lt;p&gt;public class UserAge &lt;br&gt;
{&lt;br&gt;
public static void main (String args[])&lt;br&gt;
 {&lt;br&gt;
  int user = 17;&lt;br&gt;
  if(user&amp;gt;=18)&lt;br&gt;
   {&lt;br&gt;
    System.out.println(" user is 18 or younger");&lt;br&gt;
    }&lt;br&gt;
 else&lt;br&gt;
  {&lt;br&gt;
   System.out.println(" user is older than 18");&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
user is older than 18&lt;/p&gt;
&lt;h2&gt;
  
  
  If-Else if Statement:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;The if-else if statement allows for multiple conditions to be checked in sequence. If the if condition is false, the program checks the next else if condition, and so on. &lt;br&gt;
--&amp;gt;In else if statements, the conditions are checked from the top-down, if the first block returns true, the second and the third blocks will not be checked, but if the first if block returns false, the second block will be checked.&lt;br&gt;
--&amp;gt;This checking continues until a block returns a true outcome.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (condition)
{
//Statements set 1
}
else if (condition 2)
{
//Statements set 2
}
. . .
else
{
//Statements to be executed if no condition is satisfied.
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fbr62m85espsp1vuj63w7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fbr62m85espsp1vuj63w7.png" alt="Image description" width="395" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example program:&lt;/strong&gt;&lt;br&gt;
package day1if;&lt;/p&gt;

&lt;p&gt;public class ExamResult &lt;br&gt;
{&lt;br&gt;
public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
 int mark = 65 ; &lt;br&gt;
 if (mark&amp;lt;50)&lt;br&gt;
 {&lt;br&gt;
 System.out.println("arear");&lt;br&gt;
 }&lt;br&gt;
else if (mark&amp;lt;=60)&lt;br&gt;
 {&lt;br&gt;
  System.out.println(" D grade");&lt;br&gt;
 }&lt;br&gt;
else if (mark&amp;lt;=85)&lt;br&gt;
 {&lt;br&gt;
  System.out.println(" b grade");&lt;br&gt;
 }&lt;br&gt;
else &lt;br&gt;
 {&lt;br&gt;
 System.out.println("pass A grade");&lt;br&gt;
 }&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
 b grade&lt;/p&gt;
&lt;h2&gt;
  
  
  Nested if Statement:
&lt;/h2&gt;

&lt;p&gt;--&amp;gt;Nested if in Java refers to having one if statement inside another if statement. &lt;br&gt;
--&amp;gt;If the outer condition is true the inner conditions are checked and executed accordingly. &lt;br&gt;
--&amp;gt;Nested if condition comes under decision-making statement in Java, enabling multiple branches of execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br&gt;
  1.Normal if condition checks condition independently which means each condition works on its own.&lt;br&gt;
  2.Whereas nested if checks conditions that depend on each other, which means one condition is only checked if another condition is true.&lt;/p&gt;
&lt;h2&gt;
  
  
  Syntax:
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if(condition){    
         //code to be executed    
              if(condition){  
                 //code to be executed    
        }    
    }  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Flowchart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fn4v7lmmvc72lvo1jsr5s.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fn4v7lmmvc72lvo1jsr5s.jpeg" alt="Image description" width="620" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example program:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package day1if;
public class Nestedif
{
  public static void main(String args[]) {
      int x = 30;
      int y = 10;

      if( x == 30 ) 
      {
           System.out.println("X = 30");
         if( y &amp;gt;10 ) 
           {
             System.out.print("Y = 10"); 
           }
         else if(y&amp;lt;10)
           {
             System.out.println("Y = 0");
           }
         else
         {
             System.out.println("it's false");
              if(y==20) 
                {
                  System.out.println("Y = 10");
                }
              else
              {
                  System.out.println("it's False");
              }
         }
      }
   }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
X = 30&lt;br&gt;
it's false&lt;br&gt;
it's False&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference:
&lt;/h2&gt;

&lt;p&gt;-&amp;gt;&lt;a href="https://www.javatpoint.com/types-of-statements-in-java" rel="noopener noreferrer"&gt;https://www.javatpoint.com/types-of-statements-in-java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-&amp;gt;&lt;a href="https://www.geeksforgeeks.org/conditional-statements-in-programming/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/conditional-statements-in-programming/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-&amp;gt;&lt;a href="https://www.scholarhat.com/tutorial/java/java-conditional-statements-if-else-switch" rel="noopener noreferrer"&gt;https://www.scholarhat.com/tutorial/java/java-conditional-statements-if-else-switch&lt;/a&gt;&lt;/p&gt;

</description>
      <category>program</category>
      <category>statements</category>
      <category>beginners</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Task</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Fri, 24 Jan 2025 02:56:21 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/task-2oia</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/task-2oia</guid>
      <description>&lt;h2&gt;
  
  
  Task 1:
&lt;/h2&gt;

&lt;p&gt;Task 1: &lt;br&gt;
Assignment - 0: static, non-static&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a class Called Theatre.&lt;/li&gt;
&lt;li&gt;Declare below global variables in it.
2.1. String movieName
2.2. int movie_time&lt;/li&gt;
&lt;li&gt;Add main method&lt;/li&gt;
&lt;li&gt;Inside main method, create two instances (objects),
4.1 movie1
4.2 movie2&lt;/li&gt;
&lt;li&gt;For instance movie1, add 'Jailer' as movieName and 630 as movie_time&lt;/li&gt;
&lt;li&gt;For instance movie2, add 'Leo' as movieName and 7 as movie_time&lt;/li&gt;
&lt;li&gt;Create and define a method as below.
public void watch_movie()
{
System.out.println("Watching " + movieName);
System.out.println("Show Time is " +movie_time);
}&lt;/li&gt;
&lt;li&gt;Call above method using both the instances - movie1, movie2.&lt;/li&gt;
&lt;li&gt;Go through and record your observations.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Source Code :
&lt;/h2&gt;

&lt;p&gt;public class Theatre1&lt;br&gt;
{&lt;br&gt;
  String movieName;&lt;br&gt;
  int movieTime;&lt;/p&gt;

&lt;p&gt;public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
 Theatre1 movie1 = new Theatre1();&lt;br&gt;
 Theatre1 movie2 = new Theatre1();&lt;br&gt;
 movie1.movieName = "jailer";&lt;br&gt;
 movie1.movieTime = 630;&lt;br&gt;
 movie2.movieName = "leo";&lt;br&gt;
 movie2.movieTime = 720;&lt;br&gt;
 movie1.watch_movie();&lt;br&gt;
 movie2.watch_movie();&lt;br&gt;
}&lt;br&gt;
public void watch_movie()&lt;br&gt;
{&lt;br&gt;
 System.out.println("watched: " + movieName +  " showtime: " + movieTime);&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  Output:
&lt;/h2&gt;

&lt;p&gt;watched: jailer showtime: 630&lt;br&gt;
watched: leo showtime: 720&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fueeu4wyhexus6zjg4o2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fueeu4wyhexus6zjg4o2r.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 2:
&lt;/h2&gt;

&lt;p&gt;return statement&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a class called EB_Reading&lt;/li&gt;
&lt;li&gt;Have main method in it.&lt;/li&gt;
&lt;li&gt;Create an object called assessor.&lt;/li&gt;
&lt;li&gt;Using assessor instance, call a method named 'reading'.&lt;/li&gt;
&lt;li&gt;'reading' method should return consumed units in int.&lt;/li&gt;
&lt;li&gt;Store the returned value as 'consumed_units'.&lt;/li&gt;
&lt;li&gt;Using the same 'assessor' instance, call a method
named as 'calculate'.&lt;/li&gt;
&lt;li&gt;Pass 'consumed_units' as argument to calculate.&lt;/li&gt;
&lt;li&gt;Based on the consumed_units value, find out How much Customer should pay.&lt;/li&gt;
&lt;li&gt;Print Payment value.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Source Code:
&lt;/h2&gt;

&lt;p&gt;public class EbReading &lt;br&gt;
{&lt;br&gt;
 public static void main (String args[]){&lt;br&gt;
 EbReading assessor = new EbReading();&lt;br&gt;
 int Consumed units = assessor.reading();&lt;br&gt;
 System.out.println("CU"+ Consumed units);&lt;br&gt;
 assessor.calculate(Consumed units);&lt;br&gt;
}&lt;br&gt;
 public int reading()&lt;br&gt;
 {&lt;br&gt;
   int unit1 = 100;&lt;br&gt;
   return unit1;&lt;br&gt;
}&lt;br&gt;
 public void calculate(int Consumed units)&lt;br&gt;
  {&lt;br&gt;
    int payment = Consumed units*10;&lt;br&gt;
    System.out.println("Pay: " + payment);&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  Output:
&lt;/h2&gt;

&lt;p&gt;CU: 100&lt;br&gt;
Pay: 1000&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ft9edylbgg29sljqnj53c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ft9edylbgg29sljqnj53c.png" alt="Image description" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 3:
&lt;/h2&gt;

&lt;p&gt;Add Methods in Calculator&lt;/p&gt;

&lt;p&gt;public class Calculator&lt;br&gt;
{&lt;/p&gt;

&lt;p&gt;public static void main(String[] args)&lt;br&gt;
{&lt;br&gt;
Calculator calc = new Calculator();&lt;br&gt;
calc.add();&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
public void add()&lt;br&gt;
{&lt;br&gt;
System.out.println(10+20);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;//subtract()&lt;/p&gt;

&lt;p&gt;//multiply()&lt;/p&gt;

&lt;p&gt;//divide()&lt;/p&gt;

&lt;h2&gt;
  
  
  Source code:
&lt;/h2&gt;

&lt;p&gt;public class Calculator1&lt;br&gt;
{&lt;br&gt;
int a = 10;&lt;br&gt;
float b = 20.5f;&lt;br&gt;
public static void main (String args[])&lt;br&gt;
{&lt;br&gt;
Calculator1 calc = new Calculator1();&lt;br&gt;
calc.add();&lt;br&gt;
calc.sub();&lt;br&gt;
calc.mult();&lt;br&gt;
calc.div();&lt;br&gt;
}&lt;br&gt;
public void add()&lt;br&gt;
{&lt;br&gt;
float c = a+b;&lt;br&gt;
System.out.println("Addition: "+ c);&lt;br&gt;
}&lt;br&gt;
public void sub()&lt;br&gt;
{&lt;br&gt;
float c = a-b;&lt;br&gt;
System.out.println("subtraction: "+ c);&lt;br&gt;
}&lt;br&gt;
public void mult()&lt;br&gt;
{&lt;br&gt;
float c = a*b;&lt;br&gt;
System.out.println("multiply: "+ c);&lt;br&gt;
}&lt;br&gt;
public void div()&lt;br&gt;
{&lt;br&gt;
float c = a/b;&lt;br&gt;
System.out.println("divition: "+ c);&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  Output:
&lt;/h2&gt;

&lt;p&gt;Addition: 30.5&lt;br&gt;
subtraction: -10.5&lt;br&gt;
multiply: 205.0&lt;br&gt;
divition: 0.4878049&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fsqv6iu5uoqq3isrepn5o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fsqv6iu5uoqq3isrepn5o.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>program</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Day 8 - Datatype</title>
      <dc:creator>vimala jeyakumar</dc:creator>
      <pubDate>Wed, 08 Jan 2025 09:42:27 +0000</pubDate>
      <link>https://dev.to/vimala_jeyakumar_de64a9b2/day-8-datatype-9f3</link>
      <guid>https://dev.to/vimala_jeyakumar_de64a9b2/day-8-datatype-9f3</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Datatype?&lt;/strong&gt;&lt;br&gt;
--&amp;gt; Data types specify the different sizes and values that can be stored in the variable.&lt;br&gt;
--&amp;gt; Java is a statically-typed programming language. It means, all variables must be declared before its use. That is why we need to declare variable's type and name.&lt;br&gt;
--&amp;gt; Data types in Java are of different sizes and values that can be stored in the variable that is made as per convenience and circumstances to cover up all test cases. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are two types of data types in Java:&lt;/strong&gt;&lt;br&gt;
   &lt;strong&gt;1. Primitive data types:&lt;/strong&gt; The primitive data types include boolean, char, byte, short, int, long, float and double.&lt;br&gt;
   &lt;strong&gt;2. Non-primitive data types:&lt;/strong&gt; The non-primitive data types include Strings ,Classes, Interfaces, and Arrays.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fcm704bfl1glpnk7wnlwn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fcm704bfl1glpnk7wnlwn.png" alt="Image description" width="646" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Java Primitive Data Types:&lt;/strong&gt;&lt;br&gt;
--&amp;gt; In Java language, primitive data types are the building blocks of data manipulation.&lt;br&gt;
--&amp;gt; The primitive data types include boolean, char, byte, short, int, long, float and double.&lt;br&gt;
--&amp;gt; Primitive data are only single values and have no special capabilities. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fw1ysszd1b85h4ljnbpf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fw1ysszd1b85h4ljnbpf8.png" alt="Image description" width="301" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-Primitive Data Types in Java&lt;/strong&gt;:&lt;br&gt;
 --&amp;gt;The Non-Primitive (Reference) Data Types will contain a memory address of variable values because the reference types won’t store the variable value directly in memory.&lt;br&gt;
--&amp;gt;In Java, non-primitive data types, also known as reference data types, are used to store complex objects rather than simple values.&lt;br&gt;
--&amp;gt;The non-primitive data types include Strings ,Classes, Interfaces, and Arrays.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class:&lt;/strong&gt;&lt;br&gt;
   One common non-primitive data type in Java is the class. Classes are used to create objects, which are instances of the class. A class defines the properties and behaviors of objects, including variables (fields) and methods. For example, you might create a Person class to represent a person, with variables for the person's name, age, and address, and methods to set and get these values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strings:(TBD)&lt;/strong&gt;&lt;br&gt;
    Strings are defined as an array of characters. The difference between a character array and a string in Java is, that the string is designed to hold a sequence of characters in a single variable whereas, a character array is a collection of separate char-type entities. Unlike C/C++, Java strings are not terminated with a null character. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrays:(TBD)&lt;/strong&gt;&lt;br&gt;
    Arrays are a fundamental non-primitive data type in Java that allow you to store multiple values of the same type in a single variable. Arrays have a fixed size, which is specified when the array is created, and can be accessed using an index. Arrays are commonly used to store lists of values or to represent matrices and other multi-dimensional data structures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interface:(TBD)&lt;/strong&gt;&lt;br&gt;
   Interfaces are another important non-primitive data type in Java. An interface defines a contract for what a class implementing the interface must provide, without specifying how it should be implemented. Interfaces are used to achieve abstraction and multiple inheritance in Java, allowing classes to be more flexible and reusable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example program:&lt;/strong&gt;&lt;br&gt;
source code:&lt;br&gt;
public class Players&lt;br&gt;
{&lt;br&gt;
int score; &lt;br&gt;
float strike_rate;&lt;br&gt;
public static void main(String[] args)&lt;br&gt;
{&lt;br&gt;
Players player1 = new Players(); &lt;br&gt;
Players player2 = new Players(); &lt;br&gt;
player1.score = 100; &lt;br&gt;
player2.score = 80;&lt;br&gt;
player1.strike_rate = 78.4f; &lt;br&gt;
player2.strike_rate = 65.0f; &lt;br&gt;
System.out.println(player1.score);&lt;br&gt;
System.out.println(player2.strike_rate);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
Output:&lt;br&gt;
100&lt;br&gt;
65.0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fqddzgbcmo0mqi2bb1fop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fqddzgbcmo0mqi2bb1fop.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task:&lt;/strong&gt;&lt;br&gt;
source code:&lt;br&gt;
public class Hotel&lt;br&gt;
{&lt;br&gt;
    int amount;&lt;br&gt;
    float quantity;&lt;br&gt;
public static void main(String args[])&lt;br&gt;
{&lt;br&gt;
  Hotel food1 = new Hotel();&lt;br&gt;
  Hotel food2 = new Hotel();&lt;br&gt;
  food1.amount =100;&lt;br&gt;
  food1.quantity = 50.5f;&lt;br&gt;
  food2.amount = 200;&lt;br&gt;
  System.out.println( food1.amount);&lt;br&gt;
  System.out.println( food2.quantity);&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
Output:&lt;br&gt;
100&lt;br&gt;
0.0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fm2a2vpodn4gst8po4hbp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fm2a2vpodn4gst8po4hbp.png" alt="Image description" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.javatpoint.com/java-data-types" rel="noopener noreferrer"&gt;https://www.javatpoint.com/java-data-types&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/data-types-in-java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/data-types-in-java/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://monad.edu.in/img/media/uploads/data%20types%20in%20java.pdf" rel="noopener noreferrer"&gt;https://monad.edu.in/img/media/uploads/data%20types%20in%20java.pdf&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>learning</category>
      <category>payilagam</category>
    </item>
  </channel>
</rss>
