<?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: Dinesh G</title>
    <description>The latest articles on DEV Community by Dinesh G (@dinesh_g_909f4a82c67f5bbd).</description>
    <link>https://dev.to/dinesh_g_909f4a82c67f5bbd</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%2F3334813%2F78bf61cd-3b40-4635-b90c-dd414746c856.jpg</url>
      <title>DEV Community: Dinesh G</title>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dinesh_g_909f4a82c67f5bbd"/>
    <language>en</language>
    <item>
      <title>Comparable and Comparator</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Tue, 24 Feb 2026 08:33:06 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/comparable-and-comparator-52ia</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/comparable-and-comparator-52ia</guid>
      <description>&lt;p&gt;&lt;strong&gt;Comparable Interface&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Comparable Interface is meant for &lt;strong&gt;default natural Sorting order&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is present in &lt;code&gt;Java.lang&lt;/code&gt; &lt;strong&gt;package&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;it is Contains Only one method &lt;code&gt;Compare To()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compare To() method is responsible to &lt;strong&gt;sort the elements&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You define the &lt;strong&gt;natural ordering&lt;/strong&gt; for your objects by implementing the &lt;code&gt;Comparable’s&lt;/code&gt; &lt;code&gt;compareTo(T o)&lt;/code&gt; method in your &lt;strong&gt;custom objects&lt;/strong&gt;. For example, if we want to compare the Person object based on the first name we’ll implement the &lt;strong&gt;Comparable interface&lt;/strong&gt; .&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

public class ComparatorExample {
  public static void main(String[] args) {
    ArrayList  al  = new ArrayList();
    al.add("jai");
    al.add("vijay");
    al.add("maddy");
    al.add("ajai");
    al.add("don");
    Collections.sort();
    System.out.println(al);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Comparator Interface&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Comparator Interface is meant for &lt;strong&gt;Customized Sorting Order&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is present in &lt;code&gt;Java.util&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It contains two method &lt;code&gt;Compare()&lt;/code&gt; method and &lt;code&gt;equals()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compare()method is responsible to &lt;strong&gt;sort the elements&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If we want to define a total ordering on an object that has no natural ordering or if we want to override the natural ordering then we leverage the &lt;strong&gt;Comparator interface&lt;/strong&gt; to do so. For example, if we want to override the natural ordering of &lt;code&gt;Person&lt;/code&gt; objects and compare the &lt;code&gt;Person object&lt;/code&gt; based on the age we’ll implement the &lt;strong&gt;Comparator interface&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

public class ComparatorExample implements Comparator &amp;lt;String&amp;gt;{
  public static void main(String[] args) {
    ArrayList  al  = new ArrayList();
    al.add("jai");
    al.add("vijay");
    al.add("maddy");
    al.add("ajai");
    al.add("don");
    Collections.sort(al,new ComparatorExample());
    System.out.println(al);
  }

  @Override
  public int compare(String o2, String o1) {
    return o2.compareTo(o1);
  }
}


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

&lt;/div&gt;



</description>
      <category>java</category>
      <category>react</category>
      <category>programming</category>
      <category>backend</category>
    </item>
    <item>
      <title>ArrayList and LinkedList</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Tue, 17 Feb 2026 12:49:33 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/arraylist-and-linkedlist-3fbo</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/arraylist-and-linkedlist-3fbo</guid>
      <description>&lt;p&gt;&lt;strong&gt;ArrayList: The Dynamic Array&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;ArrayList&lt;/strong&gt; is like a &lt;code&gt;dynamic array&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;It stores elements by their index, so you can quickly jump to any element you want. It can hold all sorts of elements, even null, and it’s totally fine with duplicates.&lt;/p&gt;

&lt;p&gt;Some operations in an &lt;code&gt;ArrayList&lt;/code&gt; are super fast and take the same amount of time no matter how many elements you've got. These include &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;iterator&lt;/code&gt;, &lt;code&gt;ListIterator&lt;/code&gt;, &lt;code&gt;isEmpty&lt;/code&gt;, and &lt;code&gt;size&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Think of an &lt;code&gt;ArrayList&lt;/code&gt; like a &lt;strong&gt;resizable array&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It stores elements in a contiguous block of memory (like seats in a theater). If you know the position of an element, you can instantly access it — just like finding your seat by number.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;You need fast random access&lt;/li&gt;
&lt;li&gt;You rarely insert or remove elements in the middle&lt;/li&gt;
&lt;li&gt;You deal with fixed or moderately changing lists
&lt;/li&gt;
&lt;/ul&gt;

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

public class Main {
    public static void main(String[] args) {
        ArrayList&amp;lt;String&amp;gt; shoppingList = new ArrayList&amp;lt;&amp;gt;();

        // Adding items to the shopping list
        shoppingList.add("Balloons");
        shoppingList.add("Streamers");
        shoppingList.add("Cake");
        shoppingList.add("Ice Cream");
        shoppingList.add("Soda");

        System.out.println("Shopping list for the party:");
        System.out.println(shoppingList);

        // Accessing an item by index
        String cake = shoppingList.get(2);
        System.out.println("Gotta make sure we got the cake: " + cake);

        // Checking if the list is empty
        boolean isEmpty = shoppingList.isEmpty();
        System.out.println("Is the shopping list empty? " + isEmpty);

        // Checking the size of the list
        int size = shoppingList.size();
        System.out.println("Number of items on the list: " + size);

        // Finding the index of "Ice Cream"
        int iceCreamIndex = shoppingList.indexOf("Ice Cream");
        System.out.println("Ice Cream is at index: " + iceCreamIndex);

        // Removing an item (uh oh, someone decided no soda!)
        shoppingList.remove("Soda");
        System.out.println("Shopping list after removing Soda:");
        System.out.println(shoppingList);

        // Iterating through the list with a for-each loop
        System.out.println("Checking off the items:");
        for (String item : shoppingList) {
            System.out.println("Got " + item);
        }

        // Clearing the list after the party
        shoppingList.clear();
        System.out.println("Is the shopping list empty after the party? " + shoppingList.isEmpty());

        // Adding a new item post-party (we forgot to clean up!)
        shoppingList.add("Cleaning Supplies");
        System.out.println("Post-party shopping list:");
        System.out.println(shoppingList);
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;LinkedList: The Chain Connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data structure&lt;/strong&gt; used: &lt;code&gt;Doubly linked list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;LinkedList&lt;/code&gt; is a dynamic data structure and part of the Java Collections Framework. It implements a &lt;code&gt;doubly linked list&lt;/code&gt;, meaning each element (node) stores the actual data and references to both the previous and next nodes in the sequence. &lt;/p&gt;

&lt;p&gt;A LinkedList, on the other hand, is like a chain of train cars — each car (called a node) holds data and a link to the next and previous cars.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;You frequently add or remove elements&lt;/li&gt;
&lt;li&gt;You don’t need fast random access&lt;/li&gt;
&lt;li&gt;You’re implementing queues, stacks, or iterative traversals
&lt;/li&gt;
&lt;/ul&gt;

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

public class LinkedListt {
    public static void main(String[] args) {
        LinkedList&amp;lt;String&amp;gt; queue = new LinkedList&amp;lt;&amp;gt;();

        // People join the line
        queue.add("Alice");
        queue.add("Bob");
        queue.add("Charlie");
        queue.add("Diana");
        queue.add("Eve");

        System.out.println("The line for ice cream:");
        System.out.println(queue);

        // Peek at the first person in line without removing them
        String firstPerson = queue.peek();
        System.out.println("First person in line (peek): " + firstPerson);

        // Bob gets impatient and leaves
        queue.remove("Bob");
        System.out.println("Line after Bob leaves:");
        System.out.println(queue);

        // Serve the first person in line
        String servedPerson = queue.removeFirst();
        System.out.println(servedPerson + " got served ice cream!");

        // Peek again to see who's next
        String nextPerson = queue.peek();
        System.out.println("Next person in line (peek): " + nextPerson);

        // Serve the next person
        servedPerson = queue.removeFirst();
        System.out.println(servedPerson + " got served ice cream!");

        // Check the size of the line
        int size = queue.size();
        System.out.println("Number of people left in line: " + size);

        // Clear the line because the ice cream shop ran out of ice cream
        queue.clear();
        System.out.println("Is the line empty now? " + queue.isEmpty());

        // Adding a new line just for fun
        queue.add("Frank");
        System.out.println("Frank is now first in line:");
        System.out.println(queue);

        // Remove first and last (only Frank in this case)
        queue.removeFirst();
        System.out.println("Is the line empty after Frank is served? " + queue.isEmpty());
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>java</category>
      <category>react</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Collections in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Tue, 17 Feb 2026 12:02:27 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/collections-in-java-1845</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/collections-in-java-1845</guid>
      <description>&lt;p&gt;&lt;strong&gt;Collections in Java&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Collection is a group of objects treated as a single unit.&lt;/p&gt;

&lt;p&gt;Java Collections can achieve all the operations that you perform on a data such as &lt;code&gt;searching&lt;/code&gt;, &lt;code&gt;sorting&lt;/code&gt;, &lt;code&gt;insertion&lt;/code&gt;, &lt;code&gt;manipulation&lt;/code&gt;, and &lt;code&gt;deletion&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Java Collection means a single unit of objects. &lt;/p&gt;

&lt;p&gt;Java Collection framework provides many interfaces (&lt;code&gt;Set&lt;/code&gt;, &lt;code&gt;List&lt;/code&gt;, &lt;code&gt;Queue&lt;/code&gt;, &lt;code&gt;Deque&lt;/code&gt;) and classes (&lt;code&gt;ArrayList&lt;/code&gt;, &lt;code&gt;Vector&lt;/code&gt;, &lt;code&gt;LinkedList&lt;/code&gt;, &lt;code&gt;PriorityQueue&lt;/code&gt;, &lt;code&gt;HashSet&lt;/code&gt;, &lt;code&gt;LinkedHashSet&lt;/code&gt;, &lt;code&gt;TreeSet&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;(JCF)&lt;/code&gt; is a unified architecture of interface and class that help store ,organize and manipulicate groups of objects efficiently .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a framework&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A framework provides a ready-made structure of classes and interfaces for building software applications efficiently.&lt;/p&gt;

&lt;p&gt;It simplifies adding new features by offering reusable components that perform similar tasks, eliminating the need to create a framework from scratch for each new project.&lt;/p&gt;

&lt;p&gt;This approach enhances object-oriented design, making development quicker, more consistent, and reliable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It provides readymade architecture.&lt;/li&gt;
&lt;li&gt;It represents a set of classes and interfaces.&lt;/li&gt;
&lt;li&gt;It is optional.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Collection Framework&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interface &lt;/li&gt;
&lt;li&gt;Implemention entations &lt;/li&gt;
&lt;li&gt;Algorithms&lt;/li&gt;
&lt;li&gt;(c++ Standard Templates library (STL))&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common Interface&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;List&lt;/code&gt; =&amp;gt; Ordered ,Allow Duplicates, Maintain Insertion order.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set&lt;/code&gt; =&amp;gt; No Duplicate ,No insertion Order&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Map&lt;/code&gt; =&amp;gt; Stores Key value pairs (not part of collection interface but in framework).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Readymade data Structure &lt;/li&gt;
&lt;li&gt;Dynamic Size&lt;/li&gt;
&lt;li&gt;Standardized API&lt;/li&gt;
&lt;li&gt;Built in Algorithms&lt;/li&gt;
&lt;li&gt;Flexible and Efficient &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>react</category>
      <category>software</category>
    </item>
    <item>
      <title>Interface in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Mon, 09 Feb 2026 14:34:21 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/interface-in-java-222o</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/interface-in-java-222o</guid>
      <description>&lt;p&gt;&lt;strong&gt;Interface in Java&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;An interface in the Java programming language is defined as an abstract type used to specify the behavior of a class. It is a blueprint of a behavior and contains static constants and abstract methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax for Java Interfaces&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;interface {
    // declare constant fields
    // declare methods that are abstract 
    // by default.   
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To declare an interface, use the &lt;code&gt;interface&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;It is used to provide total abstraction. That means all the methods in an interface are declared with an empty body and are public, and all fields are public, static, and final by default. A class that implements an interface must implement all the methods declared in the interface. To implement the interface, use the &lt;code&gt;implements keyword.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uses of Interfaces in Java&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; It is used to achieve total abstraction.&lt;/li&gt;
&lt;li&gt; Since Java does not support multiple inheritances in the case of a class, by using an interface, it can achieve multiple inheritances.&lt;/li&gt;
&lt;li&gt; Any class can extend only one class but can implement multiple interfaces.&lt;/li&gt;
&lt;li&gt; It is also used to achieve loose coupling.&lt;/li&gt;
&lt;li&gt; Interfaces are used to implement abstraction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to Use Class and Interface?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use a Class when&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Use a class when you need to represent a real-world entity with attributes (fields) and behaviors (methods).&lt;/li&gt;
&lt;li&gt;    Use a class when you need to create objects that hold state and perform actions&lt;/li&gt;
&lt;li&gt;    Classes are used for defining templates for objects with specific functionality and properties.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use an Interface when&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use an interface when you need to define a contract for behavior that multiple classes can implement.&lt;/li&gt;
&lt;li&gt;    Interface is ideal for achieving abstraction and multiple inheritance.&lt;/li&gt;
&lt;li&gt;    Implementation: To implement an interface, we use the keyword implements&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>java</category>
    </item>
    <item>
      <title>Exception Handling in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Mon, 09 Feb 2026 14:17:51 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/exception-handling-in-java-31ed</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/exception-handling-in-java-31ed</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java exceptions are events that disrupt the normal flow of a program during runtime.&lt;/p&gt;

&lt;p&gt;Java exceptions are events that disrupt the normal flow of a program during runtime. They are objects representing errors or unusual conditions that the program should handle to prevent crashing or unexpected behaviour.&lt;/p&gt;

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

&lt;p&gt;You should use exception handling to manage conditions that are outside the normal ,expected flow of a program.&lt;/p&gt;

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

&lt;p&gt;Exception handling is crucial for writing reliable and robust applications &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preverts abnormal program termination &lt;/li&gt;
&lt;li&gt;Provides meaningful error message &lt;/li&gt;
&lt;li&gt;Ensure resources cleanup &lt;/li&gt;
&lt;li&gt;Promotes code robustness &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Types of Java Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1.Checked Exceptions&lt;/p&gt;

&lt;p&gt;These are exceptions that are checked at compile time&lt;/p&gt;

&lt;p&gt;The program must handle these exceptions using a try-catch block or declare them using the throws keyword.&lt;/p&gt;

&lt;p&gt;Examples: &lt;code&gt;IOException, SQLException, FileNotFoundException&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2.Unchecked Exceptions&lt;/p&gt;

&lt;p&gt;These occur during runtime and are not checked at compile time.&lt;/p&gt;

&lt;p&gt;They usually result from programming errors, such as logic mistakes or improper use of APIs.&lt;/p&gt;

&lt;p&gt;Examples: &lt;code&gt;NullPointerException, ArrayIndexOutOfBoundsException, ArithmeticException&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;3.Errors&lt;/p&gt;

&lt;p&gt;Represent serious problems that applications should not try to catch.&lt;/p&gt;

&lt;p&gt;Examples: &lt;code&gt;OutOfMemoryError, StackOverflowError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exception Handling in Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;try&lt;/code&gt;: Code that might throw an exception is enclosed in a try block.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;catch&lt;/code&gt;: Handles specific exceptions thrown by the try block.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;finally&lt;/code&gt;: Block that is always executed after try and catch, regardless of whether an exception occurred.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;throw&lt;/code&gt;: Used to explicitly throw an exception.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;throws&lt;/code&gt;: Declares exceptions that a method might throw.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax Example&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;import java.io.*;

public class ExceptionExample {
    public static void main(String[] args) {
        try {
            // Code that may throw an exception
            FileInputStream file = new FileInputStream("test.txt");
        } catch (FileNotFoundException e) {
            // Handling the exception
            System.out.println("File not found: " + e.getMessage());
        } finally {
            // Always executed
            System.out.println("Execution completed.");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Commonly Used Exception Classes&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;IOException&lt;/code&gt;: Input-output operations failure.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SQLException&lt;/code&gt;: Database access errors.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ClassNotFoundException&lt;/code&gt;: Class not found during runtime.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ArithmeticException&lt;/code&gt;: Invalid arithmetic operations (e.g., division by zero).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NullPointerException&lt;/code&gt;: Attempt to use an object reference that is null.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;IllegalArgumentException&lt;/code&gt;: Method has been passed an inappropriate argument.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Custom Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can create custom exceptions by extending the Exception or &lt;code&gt;RuntimeException&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyCustomException extends Exception {
    public MyCustomException(String message) {
        super(message);
    }
}

public class CustomExceptionExample {
    public static void main(String[] args) {
        try {
            throw new MyCustomException("Custom error occurred");
        } catch (MyCustomException e) {
            System.out.println(e.getMessage());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Different Types of Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Java, there are different kinds of problems, or exceptions. For example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`ArithmeticException`: When you try to do math that doesn’t make sense, like dividing by zero.
`NullPointerException`: When you try to use something that doesn’t exist yet (like trying to open a treasure chest that isn’t there).
`ArrayIndexOutOfBoundsException`: When you try to reach into an array for something that's beyond its limits, like asking for the 11th cookie in a jar that only has 10.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Cleaning Up and Making Custom Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The finally Block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you’re playing a game and you find treasure, but whether you succeed or not, you always want to close the treasure chest when you're done. In Java, the finally block is like making sure the treasure chest is always closed, no matter what happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the finally Block?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;finally block&lt;/code&gt; is a piece of code that always runs, whether an exception happens or not. It’s used to clean up, like closing a file, stopping a timer, or putting away the treasure chest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s See an Example&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;public class FinallyExample {
    public static void main(String[] args) {
        try {
            int result = 10 / 0; // This will cause an exception.
        } catch (ArithmeticException e) {
            System.out.println("Oops! You can’t divide by zero.");
        } finally {
            System.out.println("This will always run, no matter what.");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here’s what happens&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;try&lt;/code&gt; block tries to do something risky.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;catch&lt;/code&gt; block catches the problem if it happens.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;finally&lt;/code&gt; block always runs, even if there’s no problem.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>java</category>
      <category>software</category>
    </item>
    <item>
      <title>Exception Handling in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Mon, 09 Feb 2026 14:12:43 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/exception-handling-in-java-2ndi</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/exception-handling-in-java-2ndi</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java exceptions are events that disrupt the normal flow of a program during runtime.&lt;/p&gt;

&lt;p&gt;Java exceptions are events that disrupt the normal flow of a program during runtime. They are objects representing errors or unusual conditions that the program should handle to prevent crashing or unexpected behaviour.&lt;/p&gt;

&lt;p&gt;When:&lt;/p&gt;

&lt;p&gt;You should use exception handling to manage conditions that are outside the normal ,expected flow of a program.&lt;/p&gt;

&lt;p&gt;Why:&lt;/p&gt;

&lt;p&gt;Exception handling is crucial for writing reliable and robust applications &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preverts abnormal program termination &lt;/li&gt;
&lt;li&gt;Provides meaningful error message &lt;/li&gt;
&lt;li&gt;Ensure resources cleanup &lt;/li&gt;
&lt;li&gt;Promotes code robustness &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Types of Java Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1.Checked Exceptions&lt;/p&gt;

&lt;p&gt;These are exceptions that are checked at compile time&lt;/p&gt;

&lt;p&gt;The program must handle these exceptions using a try-catch block or declare them using the throws keyword.&lt;/p&gt;

&lt;p&gt;Examples: &lt;code&gt;IOException, SQLException, FileNotFoundException&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2.Unchecked Exceptions&lt;/p&gt;

&lt;p&gt;These occur during runtime and are not checked at compile time.&lt;/p&gt;

&lt;p&gt;They usually result from programming errors, such as logic mistakes or improper use of APIs.&lt;/p&gt;

&lt;p&gt;Examples: &lt;code&gt;NullPointerException, ArrayIndexOutOfBoundsException, ArithmeticException&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;3.Errors&lt;/p&gt;

&lt;p&gt;Represent serious problems that applications should not try to catch.&lt;/p&gt;

&lt;p&gt;Examples: &lt;code&gt;OutOfMemoryError, StackOverflowError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exception Handling in Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;try&lt;/code&gt;: Code that might throw an exception is enclosed in a try block.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;catch&lt;/code&gt;: Handles specific exceptions thrown by the try block.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;finally&lt;/code&gt;: Block that is always executed after try and catch, regardless of whether an exception occurred.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;throw&lt;/code&gt;: Used to explicitly throw an exception.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;throws&lt;/code&gt;: Declares exceptions that a method might throw.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax Example&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;import java.io.*;

public class ExceptionExample {
    public static void main(String[] args) {
        try {
            // Code that may throw an exception
            FileInputStream file = new FileInputStream("test.txt");
        } catch (FileNotFoundException e) {
            // Handling the exception
            System.out.println("File not found: " + e.getMessage());
        } finally {
            // Always executed
            System.out.println("Execution completed.");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Commonly Used Exception Classes&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;IOException&lt;/code&gt;: Input-output operations failure.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SQLException&lt;/code&gt;: Database access errors.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ClassNotFoundException&lt;/code&gt;: Class not found during runtime.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ArithmeticException&lt;/code&gt;: Invalid arithmetic operations (e.g., division by zero).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NullPointerException&lt;/code&gt;: Attempt to use an object reference that is null.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;IllegalArgumentException&lt;/code&gt;: Method has been passed an inappropriate argument.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Custom Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can create custom exceptions by extending the Exception or &lt;code&gt;RuntimeException&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyCustomException extends Exception {
    public MyCustomException(String message) {
        super(message);
    }
}

public class CustomExceptionExample {
    public static void main(String[] args) {
        try {
            throw new MyCustomException("Custom error occurred");
        } catch (MyCustomException e) {
            System.out.println(e.getMessage());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Different Types of Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Java, there are different kinds of problems, or exceptions. For example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`ArithmeticException`: When you try to do math that doesn’t make sense, like dividing by zero.
`NullPointerException`: When you try to use something that doesn’t exist yet (like trying to open a treasure chest that isn’t there).
`ArrayIndexOutOfBoundsException`: When you try to reach into an array for something that's beyond its limits, like asking for the 11th cookie in a jar that only has 10.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Cleaning Up and Making Custom Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The finally Block&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you’re playing a game and you find treasure, but whether you succeed or not, you always want to close the treasure chest when you're done. In Java, the finally block is like making sure the treasure chest is always closed, no matter what happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the finally Block?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;finally block&lt;/code&gt; is a piece of code that always runs, whether an exception happens or not. It’s used to clean up, like closing a file, stopping a timer, or putting away the treasure chest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s See an Example&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;public class FinallyExample {
    public static void main(String[] args) {
        try {
            int result = 10 / 0; // This will cause an exception.
        } catch (ArithmeticException e) {
            System.out.println("Oops! You can’t divide by zero.");
        } finally {
            System.out.println("This will always run, no matter what.");
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here’s what happens&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;try&lt;/code&gt; block tries to do something risky.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;catch&lt;/code&gt; block catches the problem if it happens.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;finally&lt;/code&gt; block always runs, even if there’s no problem.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>java</category>
      <category>software</category>
    </item>
    <item>
      <title>Types of Inheritances</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Mon, 24 Nov 2025 07:05:45 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/types-of-inheritances-1b2f</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/types-of-inheritances-1b2f</guid>
      <description>&lt;p&gt;&lt;strong&gt;Types Of Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Single Level Inheritance&lt;/li&gt;
&lt;li&gt; Multi Level Inheritance&lt;/li&gt;
&lt;li&gt; Hierarchical Inheritance&lt;/li&gt;
&lt;li&gt; Multiple Inheritance&lt;/li&gt;
&lt;li&gt; Hybrid Inheritance&lt;/li&gt;
&lt;/ul&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%2Fq82go8tdstmhgi092tgv.webp" 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%2Fq82go8tdstmhgi092tgv.webp" alt=" " width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;=&amp;gt; Java does &lt;strong&gt;not support multiple or hybrid inheritance&lt;/strong&gt; through classes because it can lead to the &lt;strong&gt;diamond problem&lt;/strong&gt;, resulting in ambiguity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Level Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Multilevel inheritance is a type of inheritance where one child class inherits the properties and behaviors of one parent class. It means there is only one parent and one child class.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;class parent_class_name {
    void eat() { }
}

class child_class_name extends parent_class_name {
    void bark() { }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Multi level Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Multilevel inheritance is a type of inheritance where a class inherits from a child class which is already inherited from another class. It means there is a chain of inheritance, one parent, one  child, and one grandchild class.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;class parent_class_name {

}

class child_class_name extends parent_class_name {

}

class grand_child_class_name extends child_class_name {

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Hierarchical inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hierarchical inheritance is a type of inheritance where a single parent class is inherited by multiple child classes. In this structure, all child classes share the common properties and behaviors of the parent class, but they can also define their unique features.&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;class parent_class_name {

}

class child_class_name_1 extends parent_class_name {

}

class child_class_name_2 extends parent_class_name {

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

&lt;/div&gt;



</description>
      <category>java</category>
      <category>beginners</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>Inheritances in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Mon, 24 Nov 2025 06:22:09 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/inheritances-in-java-8cj</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/inheritances-in-java-8cj</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is inheritances ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An object of one class acting as an object of another class.&lt;/p&gt;

&lt;p&gt;Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOPs (Object Oriented Programming system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[ Extends keyword -&amp;gt; child to parent ]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;=&amp;gt; is a Relationship&lt;br&gt;
=&amp;gt; has a Relationship&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subclass&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The class that extends the features of another class is known as child class, subclass or derived class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Superclass&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The class whose properties and functionalities are used (inherited) by another class is known as parent class, superclass or Base class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Inheritance enables overriding, allowing the subclass to provide a meaningful implementation of a superclass method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It promotes reusability by allowing the subclass to use the methods and fields defined in the parent class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When changes are needed, updating the code in the superclass automatically reflects across all subclasses, simplifying maintenance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inheritance helps avoid code duplication by placing common logic in the superclass and sharing it across multiple classes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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;class Parent {
    void display() {
        System.out.println(" parent class.");
    }
}

class Child extends Parent {
    void show() {
        System.out.println(" child class.");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>beginners</category>
      <category>react</category>
      <category>programming</category>
    </item>
    <item>
      <title>Package in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Sat, 22 Nov 2025 18:13:44 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/package-in-java-4f0f</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/package-in-java-4f0f</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Package in java&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;A package is a namespace that organizes a set of related classes and interfaces.&lt;/p&gt;

&lt;p&gt;Conceptually you can think of packages as being similar to different folders on your computer.&lt;/p&gt;

&lt;p&gt;You might keep HTML pages in one folder, images in another, and scripts or applications in yet another.&lt;/p&gt;

&lt;p&gt;Because software written in the Java programming language can be composed of hundreds or thousands of individual classes, it makes sense to keep things organized by placing related classes and interfaces into packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organization&lt;/strong&gt;: Keeps related classes together&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid name conflict&lt;/strong&gt;: if two classes with same name can exist in different packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Access Control&lt;/strong&gt;: You can set visibility (like public, protected) using package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reusability&lt;/strong&gt;: Easier to use classes in other projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Packages in Java&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built-in Packages:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are predefined collections of classes and interfaces provided by Java to perform common tasks.&lt;/p&gt;

&lt;p&gt;** Examples include**:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;java.util&lt;/li&gt;
&lt;li&gt;java.io&lt;/li&gt;
&lt;li&gt;java.lang&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;User-defined Packages:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are packages Created by developers to group related classes and interfaces Code, helping to Organize and avoid name Conflicts.&lt;/p&gt;

&lt;p&gt;Developers Create Custom packages to Structure their applications in a logical manner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eg&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 mypackage;

public class Message {
    public void showMessage() {
        System.out.println("Hello from mypackage!");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>beginners</category>
      <category>java</category>
      <category>react</category>
    </item>
    <item>
      <title>Constructor overloading in java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Sat, 15 Nov 2025 10:36:32 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/constructor-overloading-in-java-232c</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/constructor-overloading-in-java-232c</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Constructor Overloading?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constructor overloading in Java means having multiple constructors in the same class, each with a different parameter list.&lt;/li&gt;
&lt;li&gt;The constructors are differentiated by the number and types of their parameters.&lt;/li&gt;
&lt;li&gt;This allows you to create objects with varying initial states based on what data is available when the object is instantiated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Use Constructor Overloading?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Constructor overloading is useful for several reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    &lt;strong&gt;Flexibility&lt;/strong&gt;: It provides multiple ways to create objects with different initial values.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Convenience&lt;/strong&gt;: Users of your class can choose which constructor to call based on the information they have.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Code Reusability&lt;/strong&gt;: It allows for a default setup while still enabling customization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example of Constructor Overloading&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s consider a simple example of an Employee class to see how constructor overloading works&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Employee {
    private String name;
    private int id;
    private double salary;

    // Constructor 1: No parameters
    public Employee() {
        this.name = "Unknown";
        this.id = 0;
        this.salary = 0.0;
    }

    // Constructor 2: One parameter (name)
    public Employee(String name) {
        this.name = name;
        this.id = 0;
        this.salary = 0.0;
    }

    // Constructor 3: Two parameters (name and id)
    public Employee(String name, int id) {
        this.name = name;
        this.id = id;
        this.salary = 0.0;
    }

    // Constructor 4: Three parameters (name, id, and salary)
    public Employee(String name, int id, double salary) {
        this.name = name;
        this.id = id;
        this.salary = salary;
    }

    public void displayInfo() {
        System.out.println("Name: " + name + ", ID: " + id + ", Salary: " + salary);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How Does It Work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the Employee class above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Constructor 1&lt;/strong&gt; is a no-argument constructor that sets default values for the &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;id&lt;/code&gt;, and &lt;code&gt;salary&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Constructor 2&lt;/strong&gt; allows you to set the name, with id and salary defaulting to 0.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Constructor 3&lt;/strong&gt; lets you set both &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;id&lt;/code&gt;, while salary still defaults to 0.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Constructor 4&lt;/strong&gt; gives you the flexibility to set all three fields: &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;id&lt;/code&gt;, and &lt;code&gt;salary&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>java</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Methods in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Sat, 15 Nov 2025 10:21:29 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/methods-in-java-55p8</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/methods-in-java-55p8</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is methods in java&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Method :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A method is a block of code that performs a specific task and declared within the class. Methods are fundamental to object-oriented programming in Java, as they encapsulate the behavior of objects.&lt;/li&gt;
&lt;li&gt;Set of instructions for achieving a specific-tasks - with a name (or) with or without arguments (or) with or without return datatype.&lt;/li&gt;
&lt;li&gt;If we do not return any value, we should mention &lt;code&gt;void&lt;/code&gt; before method name.&lt;/li&gt;
&lt;li&gt;Modularity&lt;/li&gt;
&lt;li&gt;Code Reusability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;employee1.enquiry();&lt;br&gt;
employee1.enquiry(1234);&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private void enquiry(int accNo) {
    System.out.println("Balance enquiry");

}

private void enquiry() {
    System.out.println("General enquiry");

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

&lt;/div&gt;



&lt;p&gt;Same method name with different number of arguments is called Method overloading.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;employee1.enquiry(15.3f);&lt;br&gt;
private void enquiry(float gold) {&lt;br&gt;
System.out.println("Gold rate please");&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Same method name with different type of arguments is also known as Method overloading.&lt;/p&gt;

&lt;p&gt;Another name called Compile time polymorphism.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Methods&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    &lt;strong&gt;User-Defined Methods&lt;/strong&gt;: Created by the programmer to perform custom tasks.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Standard Library Methods&lt;/strong&gt;: Predefined methods provided by Java's API (e.g., &lt;code&gt;System.out.println()&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why use methods?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    &lt;strong&gt;Code Reusability&lt;/strong&gt;: Define code once and call it multiple times.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Modularity&lt;/strong&gt;: Break down complex programs into smaller, manageable units.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Readability and Maintainability&lt;/strong&gt;: Improve code structure and make it easier to understand and debug&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>java</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Variable and Objects in Java</title>
      <dc:creator>Dinesh G</dc:creator>
      <pubDate>Thu, 13 Nov 2025 17:09:22 +0000</pubDate>
      <link>https://dev.to/dinesh_g_909f4a82c67f5bbd/variable-and-objects-in-java-48io</link>
      <guid>https://dev.to/dinesh_g_909f4a82c67f5bbd/variable-and-objects-in-java-48io</guid>
      <description>&lt;p&gt;&lt;strong&gt;Variable and Objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Variable in Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Java Variable is a name given to a memory location that stores data. It acts as Contains to hold Values that Canused and changed during program execution Variable make it store,retrieve and manipulate information while running program, Each Variable has data type that defined what kind Value it Can store Such as int,float, String.&lt;/p&gt;

&lt;p&gt;Variables are containers for storing data values. It acts like a name given to a value stored in memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This can be classified into two types&lt;/strong&gt; : local and global variable.&lt;/p&gt;

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

&lt;p&gt;int age = 21;&lt;/p&gt;

&lt;p&gt;Here int - data type&lt;br&gt;
age - variable name&lt;br&gt;
21 - value assigned to a variable&lt;/p&gt;

&lt;p&gt;Local variable:&lt;/p&gt;

&lt;p&gt;Created when a block is entered into the storage, and then it calls and destroys the block just after exiting from the function (TBH)&lt;/p&gt;

&lt;p&gt;A local variable is declared inside a function or block and can only be accessed from within that function or block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eg:&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;public class Home{
public static void main(String[] args){
String name = "Flower";
int age = 21;
System.out.println(name);
System.out.println(age);

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

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flower
21
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Global variable&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Concepts&lt;/strong&gt;:&lt;br&gt;
&lt;strong&gt;Variable Types:&lt;/strong&gt; Variables are categorized into &lt;code&gt;global (Field)&lt;/code&gt; and &lt;code&gt;local&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Global variables can be &lt;code&gt;static or non static&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Global Variable Definition: A global variable is declared outside of any function or accessible block and can be accessed from anywhere in the code.&lt;/p&gt;

&lt;p&gt;Risks of Global Variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They can be accidentally overwritten.&lt;/li&gt;
&lt;li&gt;They persist throughout the program, consuming memory.&lt;/li&gt;
&lt;li&gt;In large &lt;code&gt;codebases&lt;/code&gt;, they can cause naming conflicts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is declared outside the methods or blocks and can be accessed anywhere in the program. This can be further divided into two types : &lt;code&gt;static and non-static.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static variable&lt;/strong&gt;: This variable is declared using static keyword inside a class. It is shared by all objects in class and has 1 memory copy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eg:&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;public class House{
public static String name = "Dinesh";
static int Doorno = 30;
public static void main(String[] args){
System.out.println(name);
System.out.println(Doorno);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&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;Dinesh
30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Non-static&lt;/strong&gt;: This variable is declared to a specific object information. It has multiple memory copy based on object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ex&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;public class House{
String name = "Flower";
int age = 21;
public static void main(String args[]){
System.out.println(name);
System.out.println(age);
}
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the Object Class?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An object in Java is a basic unit of Object-Oriented Programming and represents real-life entities. Objects are the instances of a class that are created to use the attributes and methods of a class. A typical Java program creates many objects, which as you know, interact by invoking methods.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;An object consists of *&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;State&lt;/code&gt; : It is represented by attributes of an object. It also reflects the properties of an object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eg&lt;/strong&gt;: what the objects have, Student have a first name, last name, age, etc.&lt;br&gt;
&lt;code&gt;Behavior&lt;/code&gt; : It is represented by the methods of an object. It also reflects the response of an object with other objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eg&lt;/strong&gt;: what the objects do, Student attend a course "Java for beginners".&lt;br&gt;
&lt;code&gt;Identity&lt;/code&gt; : It gives a unique name to an object and enables one object to interact with other objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eg&lt;/strong&gt;: what makes them unique, Student have Student-ID-number, or an email which is unique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;State&lt;/strong&gt;&lt;br&gt;
State is basically of two types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Statically Typed Programming Language&lt;/li&gt;
&lt;li&gt;Dynamically Typed Programming Language&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Statically Typed Programming Language:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In statically typed programming languages, type checking occurs at compile time. At compile time, source code in a specific programming language is converted to a machine-readable format. This means that before source code is compiled, the type associated with each and every single variable must be known. Some common examples of programming languages that belong to this category are Java, Haskell, C, C++, C#, Scala, Kotlin, Fortran, Go, Pascal, and Swift.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamically Typed Programming Language&lt;/strong&gt;&lt;br&gt;
In dynamically typed languages, type checking takes place at runtime or execution time. This means that variables are checked against types only when the program is executing. Some examples of programming languages that belong to this category are Python, JavaScript, Lisp, PHP, Ruby, Perl, Lua, and Tcl.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>java</category>
    </item>
  </channel>
</rss>
