<?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: Preethi Nandhagopal</title>
    <description>The latest articles on DEV Community by Preethi Nandhagopal (@preethi_nandhagopal_6d075).</description>
    <link>https://dev.to/preethi_nandhagopal_6d075</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%2F3380677%2Fb583daad-bd03-45f0-b366-9cf2cbd40221.png</url>
      <title>DEV Community: Preethi Nandhagopal</title>
      <link>https://dev.to/preethi_nandhagopal_6d075</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/preethi_nandhagopal_6d075"/>
    <language>en</language>
    <item>
      <title>hashCode(),toString() and clone()</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Sun, 05 Oct 2025 04:18:51 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/hashcodetostring-and-clone-44je</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/hashcodetostring-and-clone-44je</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is hashcode()?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;hashCode() provides a numeric representation of an object for faster searching in hash-based collections.&lt;/li&gt;
&lt;li&gt;If two objects are equal, they must return the same hash code, but the reverse is not always true.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is toString()?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;toString() is a method in the Object class (the root class of all Java classes).&lt;/li&gt;
&lt;li&gt;Its purpose is to return a string representation of an object.&lt;/li&gt;
&lt;li&gt;When you print an object (using System.out.println(object)), Java internally calls that object’s toString() method.&lt;/li&gt;
&lt;li&gt;Default toString() → className + "@" + hashcode.&lt;/li&gt;
&lt;li&gt;We override it to provide meaningful output of object state.&lt;/li&gt;
&lt;li&gt;Often used in debugging, logging, and printing objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is clone()?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;clone() is a method in the Object class that is used to create a copy of an object.&lt;/li&gt;
&lt;li&gt;The new object will have the same values as the original object.&lt;/li&gt;
&lt;li&gt;To use clone(), a class must implement the Cloneable interface; otherwise, it throws CloneNotSupportedException.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Shallow Copy (default clone):&lt;/li&gt;
&lt;li&gt;Copies object’s fields as they are.&lt;/li&gt;
&lt;li&gt;If the object contains references to other objects, only the references are copied (not the actual objects).&lt;/li&gt;
&lt;li&gt;Deep Copy (custom clone):&lt;/li&gt;
&lt;li&gt;Copies not only the object but also the objects it refers to.&lt;/li&gt;
&lt;li&gt;Requires overriding clone() or using serialization.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>StringBuffer/StringBuilder</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Sun, 05 Oct 2025 04:16:01 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/stringbufferstringbuilder-374p</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/stringbufferstringbuilder-374p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Disadvantages of String:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Immutability leads to memory usage&lt;/li&gt;
&lt;li&gt;Slower performance in modifications&lt;/li&gt;
&lt;li&gt;High Garbage Collection (GC) load&lt;/li&gt;
&lt;li&gt;Less efficient for dynamic text&lt;/li&gt;
&lt;li&gt;Concatenation using + inside loops is costly&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;Good for constant and read-only text.&lt;/li&gt;
&lt;li&gt;Bad for frequent modifications → use StringBuilder / StringBuffer instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is StringBuilder?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;StringBuilder is a mutable (changeable) sequence of characters.&lt;/li&gt;
&lt;li&gt;Unlike String (which is immutable), when you modify a StringBuilder object, it does not create a new object in memory — it updates the same object.&lt;/li&gt;
&lt;li&gt;It was introduced in Java 1.5 to provide a faster, non-synchronized alternative to StringBuffer.&lt;/li&gt;
&lt;li&gt;Faster than StringBuffer because it is not synchronized (not thread-safe).&lt;/li&gt;
&lt;li&gt;Efficient for concatenation, insertion, deletion inside loops or large text operations.&lt;/li&gt;
&lt;li&gt;Found in the package: java.lang.StringBuilder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What is StringBuffer in Java?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;StringBuffer is a mutable sequence of characters (like StringBuilder).&lt;/li&gt;
&lt;li&gt;The main difference: StringBuffer is synchronized → which means thread-safe (can be safely used by multiple threads).&lt;/li&gt;
&lt;li&gt;It was introduced in Java 1.0, before StringBuilder.&lt;/li&gt;
&lt;li&gt;Because of synchronization, it is slower than StringBuilder, but safer in multithreaded programs.&lt;/li&gt;
&lt;li&gt;Found in the package: java.lang.StringBuffer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Common Methods in StringBuilder and StringBuffer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;append()-&amp;gt;Adds text at the end
&lt;/li&gt;
&lt;li&gt;insert()-&amp;gt;Inserts text at given index &lt;/li&gt;
&lt;li&gt;replace()-&amp;gt;Replaces characters in range&lt;/li&gt;
&lt;li&gt;delete()-&amp;gt;Deletes characters in range &lt;/li&gt;
&lt;li&gt;reverse()-&amp;gt;Reverses the string
&lt;/li&gt;
&lt;li&gt;capacity()-&amp;gt;Returns current capacity
&lt;/li&gt;
&lt;li&gt;length()-&amp;gt;Returns current length
&lt;/li&gt;
&lt;li&gt;charAt()-&amp;gt;Returns char at index&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How StrinBuilder Difference from StringBuffer?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;StringBuffer is synchronized (thread-safe, but slower,Multithreaded program).&lt;/li&gt;
&lt;li&gt;StringBuilder is not synchronized (faster, but not thread-safe,single threaded program).&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>LinkedHashSet and Queue</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Tue, 30 Sep 2025 13:05:41 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/linkedhashset-and-queue-i3j</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/linkedhashset-and-queue-i3j</guid>
      <description>&lt;p&gt;&lt;strong&gt;LinkedHashSet:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A LinkedHashSet is a class in Java that:&lt;/li&gt;
&lt;li&gt;Implements the Set interface&lt;/li&gt;
&lt;li&gt;It is part of java.util package.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unique Elements -&amp;gt; Like all sets, it does not allow duplicates.&lt;/li&gt;
&lt;li&gt;Maintains Insertion Order -&amp;gt; Unlike HashSet (which is unordered), LinkedHashSet keeps elements in the same order you inserted them.&lt;/li&gt;
&lt;li&gt;Allows null -&amp;gt; Can store one null element.&lt;/li&gt;
&lt;li&gt;Performance -&amp;gt; Almost same as HashSet (O(1) average time for add, remove, contains).&lt;/li&gt;
&lt;li&gt;Slightly slower than HashSet because it also maintains a linked list for order.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Methods in LinkedHashSet:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Since it extends HashSet, it has the same methods:&lt;/li&gt;
&lt;li&gt;add(E e) – add element&lt;/li&gt;
&lt;li&gt;remove(Object o) – remove element&lt;/li&gt;
&lt;li&gt;contains(Object o) – check if present&lt;/li&gt;
&lt;li&gt;size() – number of elements&lt;/li&gt;
&lt;li&gt;clear() – remove all elements&lt;/li&gt;
&lt;li&gt;isEmpty() – check if empty&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;Queue is a collection interface used to hold elements before processing, typically in FIFO (First-In-First-Out) order.&lt;/li&gt;
&lt;li&gt;It is part of the Java Collections Framework and defined in:&lt;/li&gt;
&lt;li&gt;java.util.Queue&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Points:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Interface → Queue is an interface, not a class.&lt;/li&gt;
&lt;li&gt;Order → Elements are usually processed in FIFO order, though some implementations (like PriorityQueue) order them differently.&lt;/li&gt;
&lt;li&gt;Duplicates → Allowed.&lt;/li&gt;
&lt;li&gt;Nulls → Some implementations allow one null (like LinkedList), but PriorityQueue does not.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Common Queue Methods:&lt;/strong&gt;&lt;br&gt;
(Specializes methods of Collection)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;boolean add(E e) Inserts element, throws exception if full&lt;/li&gt;
&lt;li&gt;boolean offer(E e)   Inserts element, returns false if full&lt;/li&gt;
&lt;li&gt;E remove()   Removes head, throws exception if empty&lt;/li&gt;
&lt;li&gt;E poll() Removes head, returns null if empty&lt;/li&gt;
&lt;li&gt;E element()  Retrieves head, throws exception if empty&lt;/li&gt;
&lt;li&gt;E peek() Retrieves head, returns null if empty&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>LinkedList</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Tue, 30 Sep 2025 13:00:40 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/linkedlist-36im</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/linkedlist-36im</guid>
      <description>&lt;p&gt;&lt;strong&gt;LinkedList:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A LinkedList in Java is a doubly linked list implementation of the List and Deque interfaces, best when you need fast insertions and deletions but not random access.&lt;/li&gt;
&lt;li&gt;A LinkedList is a linear data structure that stores elements in nodes, where each node contains:&lt;/li&gt;
&lt;li&gt;The data (element)&lt;/li&gt;
&lt;li&gt;A reference (pointer) to the next node&lt;/li&gt;
&lt;li&gt;A reference (pointer) to the previous node (in case of doubly linked list)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Key Points:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part of Java Collections Framework -&amp;gt; Defined in java.util package.&lt;/li&gt;
&lt;li&gt;Implements List, Deque, Queue interfaces.&lt;/li&gt;
&lt;li&gt;Dynamic size -&amp;gt; Unlike arrays, it can grow or shrink dynamically.&lt;/li&gt;
&lt;li&gt;Allows duplicates &amp;amp; null -&amp;gt; Unlike Set, it allows duplicate elements and multiple null values.&lt;/li&gt;
&lt;li&gt;Not synchronized -&amp;gt; Multiple threads can cause issues if not handled properly. Use Collections.synchronizedList() if needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;add(E e), addFirst(E e), addLast(E e) → Add elements&lt;/li&gt;
&lt;li&gt;remove(), removeFirst(), removeLast() → Remove elements&lt;/li&gt;
&lt;li&gt;get(int index), getFirst(), getLast() → Access elements&lt;/li&gt;
&lt;li&gt;contains(Object o) → Check if element exists&lt;/li&gt;
&lt;li&gt;size() → Number of elements&lt;/li&gt;
&lt;li&gt;clear() → Remove all elements&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;Efficient insertion &amp;amp; deletion (O(1) if position known).&lt;/li&gt;
&lt;li&gt;Can be used as a List, Queue, or Deque.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Accessing an element by index is slower (O(n)) compared to ArrayList’s O(1).&lt;/li&gt;
&lt;li&gt;More memory usage (because of storing next &amp;amp; prev references).&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Multithreading and Thread class method</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Mon, 29 Sep 2025 04:41:56 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/multithreading-and-thread-class-method-19ph</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/multithreading-and-thread-class-method-19ph</guid>
      <description>&lt;p&gt;&lt;strong&gt;Multithreading:&lt;/strong&gt;&lt;br&gt;
In Java, multithreading is a programming concept where two or more parts of a program (called threads) execute concurrently to maximize CPU utilization.&lt;br&gt;
A thread is the smallest unit of a process.&lt;br&gt;
So, when we use multithreading, a single program (process) can perform multiple tasks at the same time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points about Multithreading in Java:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Concurrency – Multiple tasks run simultaneously within a program.&lt;/li&gt;
&lt;li&gt;Lightweight – Threads are smaller and faster than processes since they share the same memory space (heap).&lt;/li&gt;
&lt;li&gt;Independent Execution – Each thread runs independently; if one thread faces an exception, others can still continue.&lt;/li&gt;
&lt;li&gt;Java Support – Java provides built-in support for multithreading via:&lt;/li&gt;
&lt;li&gt;Thread class&lt;/li&gt;
&lt;li&gt;Runnable interface&lt;/li&gt;
&lt;li&gt;Executor framework (for advanced thread handling)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Multithreading:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better CPU utilization (perform multiple operations at once).&lt;/li&gt;
&lt;li&gt;Faster execution (tasks run in parallel).&lt;/li&gt;
&lt;li&gt;Improves responsiveness (e.g., GUI apps remain responsive while performing background tasks).&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Complexity – Writing multithreaded programs is harder.&lt;/li&gt;
&lt;li&gt;Synchronization issues – Risk of race conditions if multiple threads access shared resources.&lt;/li&gt;
&lt;li&gt;Debugging difficulty – Errors may be non-deterministic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Thread class method:&lt;/strong&gt;&lt;br&gt;
The Thread class in Java (in java.lang package) provides several important methods to create, control, and manage threads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commonly Used Thread Class Methods:&lt;/strong&gt;&lt;br&gt;
1)&lt;strong&gt;start():&lt;/strong&gt;&lt;br&gt;
Starts a new thread and calls the run() method internally.&lt;br&gt;
You should never call run() directly; use start().&lt;br&gt;
2)&lt;strong&gt;run():&lt;/strong&gt;&lt;br&gt;
Defines the task to be executed by the thread.&lt;br&gt;
Must be overridden when extending Thread or implementing Runnable.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Wrapper Class</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Sat, 27 Sep 2025 05:19:58 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/wrapper-class-big</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/wrapper-class-big</guid>
      <description>&lt;p&gt;&lt;strong&gt;Wrapper Class:&lt;/strong&gt;&lt;br&gt;
In Java, a Wrapper Class is a class that wraps (or “converts”) a primitive data type into an object.&lt;br&gt;
This allows primitives to be treated as objects, so you can use them in Collections or call methods on them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primitive Types and Their Wrapper Classes:&lt;/strong&gt;&lt;br&gt;
Primitive Type  Wrapper Class&lt;br&gt;
byte        -&amp;gt;    Byte&lt;br&gt;
short       -&amp;gt;    Short&lt;br&gt;
int     -&amp;gt;   Integer&lt;br&gt;
long        -&amp;gt;  Long&lt;br&gt;
float       -&amp;gt;    Float&lt;br&gt;
double      -&amp;gt;    Double&lt;br&gt;
char        -&amp;gt;    Character&lt;br&gt;
boolean     -&amp;gt;  Boolean&lt;/p&gt;

&lt;p&gt;Why Wrapper Classes are Needed ?&lt;br&gt;
1)Collections Requirement:&lt;br&gt;
Collections (like ArrayList) can store objects only, not primitives.&lt;br&gt;
ArrayList list = new ArrayList&amp;lt;&amp;gt;(); // int cannot be used directly&lt;br&gt;
2)Utility Methods:&lt;br&gt;
Wrapper classes provide useful methods, e.g., Integer.parseInt(), Double.valueOf().&lt;br&gt;
3)Type Conversion:&lt;br&gt;
Convert between strings and numbers.&lt;br&gt;
int num = Integer.parseInt("123");&lt;br&gt;
String str = Integer.toString(123);&lt;br&gt;
4)Autoboxing and Unboxing:&lt;br&gt;
Java automatically converts between primitives and wrapper objects:&lt;br&gt;
Integer i = 10; // autoboxing&lt;br&gt;
int j = i;      // unboxing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;br&gt;
Primitive → basic data type, faster, stored in stack, no methods.&lt;br&gt;
Wrapper Class → object version of primitive, stored in heap, can be used in Collections, has useful methods.&lt;/p&gt;

&lt;p&gt;Why Objects are in Heap, Not Stack?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic Size:&lt;/li&gt;
&lt;li&gt;Objects can vary in size at runtime.&lt;/li&gt;
&lt;li&gt;Stack memory is fixed and small → not suitable for variable-size objects.&lt;/li&gt;
&lt;li&gt;Long Lifetime:&lt;/li&gt;
&lt;li&gt;Objects may need to live beyond the method that created them.&lt;/li&gt;
&lt;li&gt;Stack variables disappear when the method ends.&lt;/li&gt;
&lt;li&gt;Heap objects can stay as long as they are referenced.&lt;/li&gt;
&lt;li&gt;Shared Access:&lt;/li&gt;
&lt;li&gt;Multiple methods or threads may access the same object.&lt;/li&gt;
&lt;li&gt;Stack memory is method-specific → cannot be shared.&lt;/li&gt;
&lt;li&gt;Garbage Collection:&lt;/li&gt;
&lt;li&gt;Heap allows automatic memory management using Garbage Collector.&lt;/li&gt;
&lt;li&gt;Stack is automatically cleared, but you cannot track object references globally.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Set, HashSet, TreeSet and its Methods</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Sat, 27 Sep 2025 05:02:35 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/set-hashset-treeset-and-its-methods-4i3j</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/set-hashset-treeset-and-its-methods-4i3j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Set:&lt;/strong&gt;&lt;br&gt;
A Set is a collection that does not allow duplicate elements. It models the mathematical set abstraction, which means each element is unique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HashSet:&lt;/strong&gt;&lt;br&gt;
HashSet is a class in Java that implements the Set interface. &lt;br&gt;
It stores unique elements, does not maintain insertion order, allows one null element, and provides fast operations using a hash table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HashSet is a class in java.util package.&lt;/li&gt;
&lt;li&gt;It implements the Set interface.&lt;/li&gt;
&lt;li&gt;It stores unique elements only (no duplicates allowed).&lt;/li&gt;
&lt;li&gt;It does not maintain insertion order.&lt;/li&gt;
&lt;li&gt;It allows one null element.&lt;/li&gt;
&lt;li&gt;Internally, it uses a hash table for storage, which provides fast access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Commonly Used Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;add(E e) → adds element.&lt;/li&gt;
&lt;li&gt;remove(Object o) → removes element.&lt;/li&gt;
&lt;li&gt;contains(Object o) → checks if element exists.&lt;/li&gt;
&lt;li&gt;isEmpty() → checks if set is empty.&lt;/li&gt;
&lt;li&gt;size() → number of elements.&lt;/li&gt;
&lt;li&gt;clear() → removes all elements.&lt;/li&gt;
&lt;li&gt;iterator() → to iterate through elements.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;TreeSet is a class in Java that implements the NavigableSet interface and is based on a Red-Black Tree (a type of self-balancing binary search tree).&lt;/li&gt;
&lt;li&gt;It is best when you need a sorted collection of unique elements and want efficient searching and range queries.&lt;/li&gt;
&lt;li&gt;Requires elements to be comparable (either implement Comparable or provide a Comparator).&lt;/li&gt;
&lt;li&gt;Slower than HashSet for add/search/remove (because HashSet is O(1), TreeSet is O(log n)).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Features of TreeSet:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sorted Order -&amp;gt; Stores elements in ascending (natural) order by default (like numbers in increasing order, strings in alphabetical order).&lt;/li&gt;
&lt;li&gt;You can also provide a custom comparator to define your own sorting.&lt;/li&gt;
&lt;li&gt;Unique Elements -&amp;gt; Like all sets, it does not allow duplicates.&lt;/li&gt;
&lt;li&gt;No Null Elements -&amp;gt; Unlike HashSet, TreeSet does not allow null values (will throw NullPointerException).&lt;/li&gt;
&lt;li&gt;Performance -&amp;gt; All basic operations (add, remove, search) take O(log n) time because of the Red-Black tree.&lt;/li&gt;
&lt;li&gt;Implements NavigableSet -&amp;gt; Provides additional methods like first(), last(), ceiling(), floor(), headSet(), tailSet(), subSet() etc.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;TreeSet Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TreeSet implements NavigableSet, so it has all methods of Set, SortedSet, and NavigableSet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Set Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;boolean add(E e) → Adds an element (returns false if already present).&lt;/li&gt;
&lt;li&gt;boolean remove(Object o) → Removes an element if present.&lt;/li&gt;
&lt;li&gt;boolean contains(Object o) → Checks if the element exists.&lt;/li&gt;
&lt;li&gt;void clear() → Removes all elements.&lt;/li&gt;
&lt;li&gt;int size() → Returns the number of elements.&lt;/li&gt;
&lt;li&gt;boolean isEmpty() → Checks if the set is empty.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>List , ArrayList and Methods</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Sat, 27 Sep 2025 04:44:50 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/list-arraylist-and-methods-3moe</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/list-arraylist-and-methods-3moe</guid>
      <description>&lt;p&gt;&lt;strong&gt;List:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A List in Java is an ordered collection from the Collection framework that allows duplicate elements and provides index-based access.&lt;br&gt;
Common implementations are ArrayList, LinkedList, Vector, and Stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of List:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1)Ordered collection → Elements are stored in insertion order.&lt;br&gt;
2)Allows duplicates → Same element can appear more than once.&lt;br&gt;
3)Index-based access → You can access elements using an index (like arrays).&lt;br&gt;
4)Dynamic in size → Unlike arrays, lists can grow or shrink at runtime.&lt;br&gt;
5)Supports CRUD operations → add, remove, update, search, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Implementations of List:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ArrayList → Fast for searching, slow for insertion/deletion in middle.&lt;/li&gt;
&lt;li&gt;LinkedList → Fast for insertion/deletion, slower for searching.&lt;/li&gt;
&lt;li&gt;Vector → Similar to ArrayList but thread-safe.&lt;/li&gt;
&lt;li&gt;Stack → Follows LIFO (Last In First Out) principle.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;An ArrayList in Java is a resizable array implementation of the List interface.&lt;br&gt;
It allows duplicate elements, maintains insertion order, and provides fast index-based access, but is not synchronized by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key features of ArrayList:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ArrayList is a class in java.util package.&lt;/li&gt;
&lt;li&gt;It is a resizable array implementation of the List interface.&lt;/li&gt;
&lt;li&gt;It stores elements in insertion order.&lt;/li&gt;
&lt;li&gt;It allows duplicate elements.&lt;/li&gt;
&lt;li&gt;It provides index-based access to elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Commonly Used Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;add(E e) -&amp;gt; Add element&lt;/li&gt;
&lt;li&gt;add(int index, E e) -&amp;gt; Insert at position&lt;/li&gt;
&lt;li&gt;get(int index) → Get element by index&lt;/li&gt;
&lt;li&gt;set(int index, E e) -&amp;gt; Update element&lt;/li&gt;
&lt;li&gt;remove(int index) / remove(Object o) → Remove element&lt;/li&gt;
&lt;li&gt;size() → Number of elements&lt;/li&gt;
&lt;li&gt;contains(Object o) -&amp;gt; Checks if element exists&lt;/li&gt;
&lt;li&gt;clear() → Removes all elements&lt;/li&gt;
&lt;li&gt;addAll(Collection c) -&amp;gt; Adds all elements from another collection.&lt;/li&gt;
&lt;li&gt;removeAll(Collection c) -&amp;gt; Removes all elements that exist in another collection.&lt;/li&gt;
&lt;li&gt;retainAll(Collection c) -&amp;gt; Keeps only the elements that exist in another collection (intersection).&lt;/li&gt;
&lt;li&gt;isEmpty() -&amp;gt; Checks if the ArrayList is empty.&lt;/li&gt;
&lt;li&gt;indexOf(Object o) -&amp;gt; Returns the index of the first occurrence of the element.&lt;/li&gt;
&lt;li&gt;lastIndexOf(Object o) -&amp;gt; Returns the index of the last occurrence of the element.subList(int fromIndex, int toIndex)&lt;/li&gt;
&lt;li&gt;Returns a part of the list (view).&lt;/li&gt;
&lt;li&gt;toArray() -&amp;gt; Converts ArrayList into an array.&lt;/li&gt;
&lt;li&gt;clone() -&amp;gt; Creates a shallow copy of the ArrayList.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Disadvantages of an Array, Framework and Collection</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Fri, 26 Sep 2025 06:29:26 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/disadvantages-of-an-array-framework-and-collection-7ap</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/disadvantages-of-an-array-framework-and-collection-7ap</guid>
      <description>&lt;p&gt;&lt;strong&gt;Disadvantages of Array:&lt;/strong&gt;&lt;br&gt;
1)Fixed Size&lt;br&gt;
2)Wasted Memory or Insufficient Capacity&lt;br&gt;
3)Only Homogeneous Data&lt;br&gt;
4)No Built-in Methods for Advanced Operations:&lt;br&gt;
Arrays don’t provide ready-made methods like searching, sorting, or resizing.&lt;br&gt;
You need to write logic manually or use Arrays utility class, which is limited.&lt;br&gt;
5)Memory Contiguity Requirement:&lt;br&gt;
Arrays require continuous memory allocation.&lt;br&gt;
For very large arrays, this may lead to OutOfMemoryError.&lt;br&gt;
6)No Type Safety for Object Arrays:&lt;br&gt;
When you create an array of objects, you can insert child class objects, but this may cause runtime errors if misused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frameworks:&lt;/strong&gt;&lt;br&gt;
A framework is a predefined set of classes, libraries, and tools provided by developers (or organizations) that helps you build applications more easily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keypoints of Frameworks:&lt;/strong&gt;&lt;br&gt;
1}Reusable Code – Provides pre-built functions and classes.&lt;br&gt;
2)Standardization – Ensures developers follow common coding practices.&lt;br&gt;
3)Productivity – Saves time because you don’t need to reinvent common features.&lt;br&gt;
4)Integration – Comes with tools for database access, security, web handling, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Frameworks:&lt;/strong&gt;&lt;br&gt;
1)Faster Development:&lt;br&gt;
Frameworks provide ready-made components, so you don’t need to code everything from scratch.&lt;br&gt;
Example: Spring Boot, Spring, Hibernate etc.&lt;br&gt;
2)Reusability:&lt;br&gt;
Common tasks (like database connections, authentication, logging) are already available.&lt;br&gt;
You can reuse code across multiple projects.&lt;br&gt;
3)Consistency &amp;amp; Standardization:&lt;br&gt;
All developers follow the same structure, making the code more organized and readable.&lt;br&gt;
4)Security:&lt;br&gt;
Many frameworks have built-in security features (like protection against SQL injection, XSS attacks, CSRF, etc.).&lt;br&gt;
5)Testability:&lt;br&gt;
Frameworks often come with built-in testing support (e.g., JUnit for unit testing in Java frameworks).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Collection:&lt;/strong&gt;&lt;br&gt;
A Collection in Java is a group of objects (called elements) that can be stored, retrieved, and manipulated together.&lt;br&gt;
Java provides the Collection Framework (in java.util package) which gives ready-made classes and interfaces to store and process data efficiently.&lt;/p&gt;

&lt;p&gt;Collection Framework Hierarchy:&lt;br&gt;
Collection (Interface)&lt;br&gt;
List → ArrayList, LinkedList, Vector, Stack&lt;br&gt;
Set → HashSet, LinkedHashSet, TreeSet&lt;br&gt;
Queue → PriorityQueue, ArrayDeque&lt;br&gt;
Note:There’s also Map (HashMap, TreeMap, LinkedHashMap), but strictly speaking Map is not part of Collection interface, it’s part of the framework.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Keywords in Exception</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Sun, 21 Sep 2025 11:07:42 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/keywords-in-exception-49dh</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/keywords-in-exception-49dh</guid>
      <description>&lt;p&gt;Keywords in Exception:&lt;br&gt;
1.What is try?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The try block contains the code that might throw an exception.&lt;/li&gt;
&lt;li&gt;Only one try is allowed, but it can be followed by multiple catch blocks and/or one finally block.&lt;/li&gt;
&lt;li&gt;Without a catch or finally, try cannot exist alone.&lt;/li&gt;
&lt;li&gt;A try block written inside another try block is called a nested try.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;What is catch?&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The catch block is used to handle exceptions that occur inside the try block.&lt;/li&gt;
&lt;li&gt;Each catch block can handle a specific type of exception (e.g., ArithmeticException, NullPointerException).&lt;/li&gt;
&lt;li&gt;Multiple catch blocks allow different handling strategies for different exceptions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;try and catch in Java&lt;br&gt;
In Java, exception handling is done using try, catch, finally, throw, and throws.&lt;br&gt;
The most commonly used ones are try and catch, which work together to handle runtime errors (exceptions) gracefully, without stopping the program abruptly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is finally?
The finally block in Java is used with try and catch for code that must execute no matter what happens (exception occurs or not).
It is mostly used for resource cleanup (closing files, database connections, releasing memory, etc.).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always Executes-&amp;gt;Code inside finally will run whether an exception occurs or not.&lt;/li&gt;
&lt;li&gt;Works with or without catch-&amp;gt;You can use try-finally (without catch) if you only want cleanup logic.&lt;/li&gt;
&lt;li&gt;Execution Order-&amp;gt;First, try executes → if exception occurs, catch executes → then finally executes.&lt;/li&gt;
&lt;li&gt;Common Use Case-&amp;gt;Closing resources like file streams, sockets, database connections, etc.&lt;/li&gt;
&lt;li&gt;Runs Even if Exception Not Caught-&amp;gt;Even if there is no matching catch block, finally still executes before program ends.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;What is throws?
The throws keyword is used in a method declaration to indicate that the method may throw one or more exceptions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declaration, not handling-&amp;gt;throws is used to declare exceptions, not to handle them.&lt;/li&gt;
&lt;li&gt;Handling is done using try-catch.&lt;/li&gt;
&lt;li&gt;Placed in Method Signature-&amp;gt;Comes after the method parameters.&lt;/li&gt;
&lt;li&gt;Example:
void myMethod() throws IOException, SQLException {
 // code
}&lt;/li&gt;
&lt;li&gt;Used for Checked Exceptions-&amp;gt;Mainly used to declare checked exceptions (like IOException, SQLException) because the compiler forces you to handle or declare them.&lt;/li&gt;
&lt;li&gt;Multiple Exceptions-&amp;gt;A method can declare multiple exceptions separated by commas.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;What is throw?
The throw keyword is used to explicitly throw an exception from a method or block of code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used to Actually Throw Exception-&amp;gt;Unlike throws (which declares), throw is used inside a method to trigger an exception.&lt;/li&gt;
&lt;li&gt;Example: throw new ArithmeticException("Cannot divide by zero");&lt;/li&gt;
&lt;li&gt;Must be Inside a Method/Block-&amp;gt;Cannot be used in method declaration (that’s throws).&lt;/li&gt;
&lt;li&gt;Always used inside method, constructor, or block.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Exception Handling</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Fri, 19 Sep 2025 05:46:59 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/exception-handling-4i9k</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/exception-handling-4i9k</guid>
      <description>&lt;p&gt;Exception Handling:&lt;br&gt;
Exception handling is a mechanism in Java that deals with runtime errors, allowing the program to continue its normal flow instead of crashing.&lt;br&gt;
An exception is an unwanted or unexpected event that occurs during the execution of a program, disrupting its normal flow.&lt;/p&gt;

&lt;p&gt;Keypoints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exceptions are problems that occur during execution, not syntax errors.&lt;/li&gt;
&lt;li&gt;When an exception occurs, Java throws the exception object.&lt;/li&gt;
&lt;li&gt;If not handled, the program terminates abnormally.&lt;/li&gt;
&lt;li&gt;Exception handling helps catch and deal with these problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exception:&lt;br&gt;
An exception in Java is an event that disrupts the normal flow of a program’s execution. It usually occurs due to errors or unexpected situations at runtime, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Division by zero&lt;/li&gt;
&lt;li&gt;Accessing a null object&lt;/li&gt;
&lt;li&gt;File not found&lt;/li&gt;
&lt;li&gt;Invalid input from the user
When an exception occurs, the normal flow of the program is interrupted, and Java creates an exception object that contains information about the errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Error:&lt;br&gt;
An error in Java is a serious problem that arises during the execution of a program and typically cannot be handled or recovered from by the program itself.&lt;br&gt;
Errors are usually caused by issues outside the application's control and indicate problems with the environment in which the program is running.&lt;/p&gt;

&lt;p&gt;Examples of error:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;OutOfMemoryError-&amp;gt;Happens when the JVM runs out of memory.&lt;/li&gt;
&lt;li&gt;StackOverflowError-&amp;gt;Happens due to infinite recursion or excessive memory use in the call stack.&lt;/li&gt;
&lt;li&gt;VirtualMachineError-&amp;gt;Issues with the JVM itself.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Types of Exceptions:&lt;br&gt;
Checked Exception:&lt;br&gt;
Definition:&lt;br&gt;
Checked exceptions are exceptions that are checked at compile-time.&lt;br&gt;
The compiler ensures that these exceptions are either caught using try-catch or declared using the throws keyword in the method signature.&lt;/p&gt;

&lt;p&gt;Key Features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The program must handle them explicitly.&lt;/li&gt;
&lt;li&gt;They typically occur due to external conditions, like file I/O errors or database problems.&lt;/li&gt;
&lt;li&gt;If you don't handle them, the compiler will give an error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
IOException-&amp;gt;Input/output errors-&amp;gt;Reading from or writing to a file that doesn't exist.&lt;br&gt;
FileNotFoundException-&amp;gt;File cannot be found-&amp;gt;Opening a file path that does not exist.&lt;/p&gt;

&lt;p&gt;Unchecked Exceptions (Runtime Exceptions):&lt;br&gt;
Definition:&lt;br&gt;
Unchecked exceptions are exceptions that are checked at runtime, not at compile-time. The compiler does not require you to handle them explicitly.&lt;/p&gt;

&lt;p&gt;Key Features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They are usually programming bugs or logic errors.&lt;/li&gt;
&lt;li&gt;Handling them is optional, but ignoring them can cause program crashes.&lt;/li&gt;
&lt;li&gt;They are subclasses of RuntimeException.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
ArithmeticException-&amp;gt;Invalid arithmetic operation-&amp;gt;Dividing by zero.&lt;br&gt;
NullPointerException-&amp;gt;Accessing a null reference-&amp;gt;Calling a method on a null object.&lt;/p&gt;

&lt;p&gt;Throwable Class:&lt;br&gt;
Root class for all exceptions and errors.&lt;br&gt;
It can be thrown or caught.&lt;br&gt;
Provides methods like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;getMessage()&lt;/li&gt;
&lt;li&gt;printStackTrace()&lt;/li&gt;
&lt;li&gt;getCause()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some basic keywords in Exceptions Handling:&lt;br&gt;
try – Block where you write code that might throw an exception.&lt;br&gt;
catch – Block that handles the exception.&lt;br&gt;
finally – Block that executes after try-catch, whether an exception occurred or not.&lt;br&gt;
throw – Used to explicitly throw an exception.&lt;br&gt;
throws – Declares exceptions that a method might throw.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Static and Non Static Block</title>
      <dc:creator>Preethi Nandhagopal</dc:creator>
      <pubDate>Tue, 16 Sep 2025 05:21:14 +0000</pubDate>
      <link>https://dev.to/preethi_nandhagopal_6d075/static-and-non-static-block-13g1</link>
      <guid>https://dev.to/preethi_nandhagopal_6d075/static-and-non-static-block-13g1</guid>
      <description>&lt;p&gt;Static and Non Static Block:&lt;br&gt;
A static block is a special block that gets executed once when the class is loaded into memory. It's used to initialize static variables or to perform setup operations &lt;br&gt;
before the main method runs.&lt;/p&gt;

&lt;p&gt;A block is a group of statements enclosed within curly braces {}. It defines a scope where variables can be declared and logic can be grouped.&lt;br&gt;
Block and Constructor are called when an object is created.&lt;/p&gt;

&lt;p&gt;Order of Execution:&lt;/p&gt;

&lt;p&gt;Static block(s) → executed when the class is loaded (only once).&lt;/p&gt;

&lt;p&gt;Instance block(s) → executed every time an object is created, before the constructor.&lt;/p&gt;

&lt;p&gt;Constructor → executed after instance blocks when an object is created.&lt;/p&gt;

&lt;p&gt;Main method → executed after class loading and static block execution. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
