<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vignesh on Medium]]></title>
        <description><![CDATA[Stories by Vignesh on Medium]]></description>
        <link>https://medium.com/@vignesh4485849?source=rss-e62ad491b97e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DzNP_Z2d2fiI61fjuTC-bQ.jpeg</url>
            <title>Stories by Vignesh on Medium</title>
            <link>https://medium.com/@vignesh4485849?source=rss-e62ad491b97e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 11:06:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vignesh4485849/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[File Handling in Java]]></title>
            <link>https://medium.com/@vignesh4485849/file-handling-in-java-d402a2b0c141?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d402a2b0c141</guid>
            <category><![CDATA[file-handling]]></category>
            <category><![CDATA[java-files]]></category>
            <category><![CDATA[java-file-handling]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Mon, 26 Oct 2026 07:33:20 GMT</pubDate>
            <atom:updated>2026-10-26T07:33:20.522Z</atom:updated>
            <content:encoded><![CDATA[<p>File handling in java means creating, reading, writing and deleting file using java program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjYRlLw3ZseELhWyRrT-JQ.png" /></figure><h4><strong><em>Key Features of File Handling</em></strong></h4><ul><li><strong>Permanent storage</strong> → Save data for future use</li><li><strong>Data retrieval</strong> → Read previously saved data</li><li><strong>Data sharing</strong> → Let multiple programs access the same file</li><li><strong>Data organization</strong> → Arrange information into files and folders</li><li><strong>File management</strong> → Create, copy, move, rename, and delete files</li></ul><h4>File Class in Java</h4><p>File class in Java used to represent the name and path of a file or Directory. This class provides the basic methods such as create, delete and get information about the file.</p><p>It is from java.IO.package.</p><pre>package com;<br><br>import java.io.File;<br>import java.io.IOException;<br><br>public class FileOperations {<br>    public static void main(String[] args) {<br>        File file = new File(&quot;sample.txt&quot;);<br><br>        // 1. Create a file<br>        try {<br>            if (file.createNewFile()) {<br>                System.out.println(&quot;File created&quot;);<br>            } else {<br>                System.out.println(&quot;File already exists&quot;);<br>            }<br>        } catch (IOException e) {<br>            System.out.println(&quot;Creation error: &quot; + e.getMessage());<br>        }<br><br>        // 2. Check existence<br>        System.out.println(&quot;Exists: &quot; + file.exists());<br><br>        // 3. Get file name<br>        System.out.println(&quot;Name: &quot; + file.getName());<br><br>        // 4. Get absolute path<br>        System.out.println(&quot;Path: &quot; + file.getAbsolutePath());<br><br>        // 5. Get file size<br>        System.out.println(&quot;Size: &quot; + file.length() + &quot; bytes&quot;);<br><br>        // 6. Check regular file<br>        System.out.println(&quot;Is file: &quot; + file.isFile());<br><br>        // 7. Check directory<br>        File folder = new File(&quot;myFolder&quot;);<br>        System.out.println(&quot;Is directory: &quot; + folder.isDirectory());<br><br>        // 8. Create directory<br>        if (folder.mkdir()) {<br>            System.out.println(&quot;Directory created&quot;);<br>        } else {<br>            System.out.println(&quot;Directory already exists or creation failed&quot;);<br>        }<br><br>        // 9. Create nested directories<br>        File nested = new File(&quot;parent/child/files&quot;);<br>        if (nested.mkdirs()) {<br>            System.out.println(&quot;Nested directories created&quot;);<br>        } else {<br>            System.out.println(&quot;Nested directories already exist or creation failed&quot;);<br>        }<br><br>        // 10. Delete file<br>        if (file.delete()) {<br>            System.out.println(&quot;File deleted&quot;);<br>        } else {<br>            System.out.println(&quot;File could not be deleted&quot;);<br>        }<br>    }<br>}</pre><h4><strong><em>I/O Stream</em></strong></h4><p>In Java, IO stream is a continue sequence or flow of data used to transfer information between java program and external source or destination. Such as a file, Network socket, or the console.</p><p><strong>Simply:</strong> I/O stream is used to read data from a source and write data to a destination.</p><p>I/O stands for input and output</p><p><strong>Input:</strong> Receiving data</p><p><strong>Output: </strong>Sending data</p><h3><strong>Types of I/O Strem in Java</strong></h3><p>Java I/O stream is categorized into two main types based on the type of data they handle.</p><ol><li><strong>Byte Stream</strong> →Handle raw binary data.</li><li><strong>Character Stream</strong> →Handle character data(text).</li></ol><h3><strong>Byte Streams</strong></h3><p>Byte stream read and write data in bytes (8bits). They are used for handling binary data such as image, audio, video files etc.</p><p><strong>Two main abstract class :</strong></p><p><strong>InputStream</strong> → Reads byte data</p><p><strong>OutputStream</strong> → Writes byte data</p><p>Since InputStream and OutputStream are abstract class we can’t directly create Object, so we use their implementations classes to create Object.</p><ul><li><strong>FileInputStream</strong>: reads raw bytes from a file.</li><li><strong>FileOutputStream</strong>: writes raw bytes to a file.</li><li><strong>BufferedInputStream</strong> / <strong>BufferedOutputStream</strong>: use buffering for faster performance.</li><li><strong>ByteArrayInputStream</strong>: reads data from a byte array as if it were an input stream.</li><li><strong>ByteArrayOutputStream</strong>: writes data into a byte array, which grows automatically.</li></ul><p><strong>FileInputStream and FileOutputStream program</strong></p><pre>try(FileOutputStream fos=new FileOutputStream(&quot;sample.txt&quot;,true);<br>     FileInputStream fis=new FileInputStream(&quot;sample.txt&quot;)){<br>            //write operation<br>            String text=&quot;Hello world!&quot;;<br>            fos.write(text.getBytes());<br>            System.out.println(&quot;\nData written successfully!&quot;);<br><br>            //read operation<br>            int letters=fis.read();<br>            while (letters!=-1){<br>                System.out.print((char)letters);<br>                letters=fis.read();<br>            }<br>            System.out.println(&quot;\nData read successful&quot;);<br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>}</pre><p>Explanation:</p><ul><li><strong>try(….)</strong> → Try with resource, wich means automatically close the resource, when the try block finish. Only resource can use this method.</li><li><strong>text.getBytes()</strong></li></ul><pre>fos.write(text.getBytes());</pre><p><em>text.getBytes() </em>→ converts the string into a byte array.</p><p><em>fos.write()</em> → writes those bytes into the file.</p><ul><li><strong>new FileInputStream(“sample.txt”,true)</strong></li></ul><pre>FileOutputStream fos = new FileOutputStream(&quot;sample.txt&quot;, true);</pre><p>This opens sample.txt for writing.</p><p>“sample.txt” → the file name.</p><p>true → append mode.</p><ul><li><strong>fis.read( )</strong></li></ul><p>This method read one byte at a time. read( ) returns an integer from 0 to 255 representing the next byte, or -1 when the end of the file is reached.</p><p><strong>Simple explanation :</strong></p><ul><li>FileOutputStream → writes bytes.</li><li>FileInputStream → reads bytes.</li><li>getBytes( ) → converts a string into bytes.</li><li>read( ) → reads one byte and returns -1 at the end of the file.</li><li>try-with-resource → closes the resources automatically.</li></ul><h4>Buffered classes</h4><p>Buffered classes are used to make reading and writing data faster and more efficient by temporily storing data in a memory area called buffer.</p><p>It is commonly used in file handling reading text and writing data.</p><p><strong>Buffer : </strong>A buffer is a tempory memory area that stores data before it process.</p><p><strong>Important Buffered class</strong></p><ul><li>BufferedReader → reads text efficiently</li><li>BufferedWriter → writes text efficiently</li><li>BufferedInputStream → read binary data efficiently</li><li>BufferedOutputStream → write binary data efficiently</li></ul><pre><br>import java.io.*;<br><br>public class Main {<br>    public static void main(String[] args) {<br><br>        // Write operation<br>        try (BufferedOutputStream bos =new BufferedOutputStream(<br>                             new FileOutputStream(&quot;demo.txt&quot;))) {<br><br>            String text = &quot;Hello world!&quot;;<br>            bos.write(text.getBytes(StandardCharsets.UTF_8));<br>            System.out.println(&quot;Data written successfully!&quot;);<br><br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>        }<br><br>        // Read operation<br>        try (BufferedInputStream bis =new BufferedInputStream(new FileInputStream(&quot;demo.txt&quot;))) <br>            int data;<br>            while ((data = bis.read()) != -1) {<br>                System.out.print((char) data);<br>            }<br>            System.out.println(&quot;\nData read successfully!&quot;);<br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>        }<br>    }<br>}</pre><p><strong>BufferedReader and BufferedWriter (Character stream)</strong></p><pre>import java.io.*;<br><br>public class Main {<br>    public static void main(String[] args) {<br><br>        // Write operation<br>        try (BufferedWriter bw =new BufferedWriter(new FileWriter(&quot;demo.txt&quot;))) {<br><br>            String text = &quot;Hello world!&quot;;<br>            bw.write(text);<br>            System.out.println(&quot;Data written successfully!&quot;);<br><br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>        }<br><br>        // Read operation<br>        try (BufferedReader br =new BufferedReader(new FileReader(&quot;demo.txt&quot;))) {<br><br>            String line;<br>            while ((line = br.readLine()) != null) {<br>                System.out.println(line);<br>            }<br>            System.out.println(&quot;Data read successfully!&quot;);<br><br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>        }<br>    }<br>}</pre><p><strong>ByteArrayInputStream and ByteArrayOutputStream</strong></p><pre>try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {<br><br>            // Write operation<br>            bos.write(&quot;Hello &quot;.getBytes(StandardCharsets.UTF_8));<br>            bos.write(&quot;Java&quot;.getBytes(StandardCharsets.UTF_8));<br><br>            System.out.println(&quot;Data written successfully!&quot;);<br><br>            // Convert output data into a byte array<br>            byte[] data = bos.toByteArray();<br>            // Read operation<br>            try (ByteArrayInputStream bis = new ByteArrayInputStream(data)) {<br>                int value;<br>                while ((value = bis.read()) != -1) {<br>                    System.out.print((char) value);<br>                }<br><br>                System.out.println(&quot;\nData read successfully!&quot;);<br>            }<br>        } catch (IOException e) {<br>            throw new RuntimeException(e);<br>        }</pre><h4><strong>Character Stream</strong></h4><p>Character stream read and write data in characters(16bits). They are used for handling text data.</p><p><strong>Two main abstract class</strong></p><p><strong>Reader</strong> → Reads character data</p><p><strong>Writer</strong> → Writes character data</p><pre><br><br>import java.io.FileWriter;<br>import java.io.FileReader;<br><br>public class Main {<br>    public static void main(String[] args) {<br><br>        // Write operation<br>        try (FileWriter fw = new FileWriter(&quot;sample.txt&quot;, true)) {<br>            String text = &quot;Hello world!&quot;;<br>            fw.write(text);<br><br>            System.out.println(&quot;Data written successfully!&quot;);<br><br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>            return;<br>        }<br><br>        // Read operation<br>        try (FileReader fr = new FileReader(&quot;sample.txt&quot;)) {<br>            int letters;<br><br>            while ((letters = fr.read()) != -1) {<br>                System.out.print((char) letters);<br>            }<br><br>            System.out.println(&quot;\nData read successfully!&quot;);<br><br>        } catch (Exception e) {<br>            System.out.println(e.getMessage());<br>        }<br>    }<br>}</pre><p><strong>read( ) method:</strong></p><p>The read( ) method is used to read data one character at a time when using FileReader, or one byte at a time when using FileInputStream.</p><pre>FileReader fr = new FileReader(&quot;sample.txt&quot;);<br>int data;<br>while ((data = fr.read()) != -1) {<br>    System.out.print((char) data);<br>}<br>fr.close();</pre><p><strong>readLine( ) method:</strong></p><blockquote>Only BufferedReader class supports readLine( ) method. <strong>It also support read( ) method.</strong></blockquote><pre>BufferedReader br = new BufferedReader(new FileReader(&quot;sample.txt&quot;));<br>String line;<br>while ((line = br.readLine()) != null) {<br>    System.out.println(line);<br>}<br>br.close();</pre><ul><li>If a line exists → returns the line as a String.</li><li>If no more lines exist → returns null.</li></ul><p><strong>ready( ) method:</strong></p><p>The ready( ) method is used to check whether a character stream is ready to be read without blocking.</p><pre> try(InputStreamReader isr=new InputStreamReader(System.in)){<br>            System.out.println(&quot;Enter some letters:&quot;);<br>            int letters=isr.read();<br>            while(isr.ready()){<br>                System.out.println((char)letters);<br>                letters=isr.read();<br>            }<br>            System.out.println(&quot;Read successful&quot;);<br>        } catch (IOException e) {<br>            System.out.println(e.getMessage());<br>}<br>try(FileReader fileReader=new FileReader(&quot;sample.txt&quot;)){<br>            int letters=fileReader.read();<br>            while(fileReader.ready()){<br>                System.out.print((char)letters);<br>                letters=fileReader.read();<br>            }<br>            System.out.println(&quot;\nReading successful..&quot;);<br>        } catch (Exception e) {<br>            throw new RuntimeException(e);<br>}</pre><ul><li><strong>br.ready( )</strong> returns <strong>true</strong> if the stream is ready for reading without blocking.</li><li>It returns <strong>false</strong> if reading would block.</li></ul><h4>Byte Stream to Character Stream</h4><p>We convert byte stream to character stream using <strong>InputStreamReader</strong> class in java.</p><pre><br>import java.io.*;<br><br>public class Main {<br>    public static void main(String[] args) {<br><br>        // Byte stream to character stream<br>        try (BufferedReader br = new BufferedReader(<br>                new InputStreamReader(System.in))) {<br><br>            System.out.print(&quot;Enter something: &quot;);<br>            String text = br.readLine();<br><br>            System.out.println(&quot;You typed: &quot; + text);<br><br>        } catch (IOException e) {<br>            System.out.println(e.getMessage());<br>        }<br>    }<br>}</pre><pre>try (FileInputStream fis = new FileInputStream(&quot;demo.txt&quot;);<br>             InputStreamReader isr =<br>                     new InputStreamReader(fis, StandardCharsets.UTF_8)) {<br><br>            int data;<br>            while ((data = isr.read()) != -1) {<br>                System.out.print((char) data);<br>            }<br>}</pre><p>Explanation :</p><ul><li>Ststem.in — receives keyboard input as a byte stream.</li><li>InputStreamReader — converts the incoming bytes into characters.</li><li>BufferedReader — adds buffering and provides the <strong>readLine( )</strong> method.</li><li>br.readLine( ) — reads the entire line entered by the user.</li></ul><h4>Character Stream to Byte Stream</h4><p>We use OutputStreamWriter</p><p>That converts character into bytes using a character encoding.</p><pre><br>import java.io.*;<br>import java.nio.charset.StandardCharsets;<br><br>public class Main {<br>    public static void main(String[] args) {<br><br>        try (OutputStreamWriter osw =new OutputStreamWriter(System.out, StandardCharsets.UTF_8)) {<br><br>            osw.write(&quot;Hello world&quot;);<br>            osw.write(97);<br>            osw.write(&#39;a&#39;);<br><br>            char[] arr = &quot;hello&quot;.toCharArray();<br>            osw.write(arr);<br><br>            osw.flush();<br><br>        } catch (IOException e) {<br>            System.out.println(e.getMessage());<br>        }<br>    }<br>}</pre><ul><li>System.out →a byte-based output stream.</li><li>OutputStreamWriter →converts characters into bytes using the selected encoding.</li><li>osw.write(97) →writes the character a, because its Unicode value is 97.</li><li>osw.write(‘a’) →writes the character a.</li><li>osw.write(arr)→writes all characters in the array.</li><li>osw.flush( ) → method used to force buffered data to be sent to its destination immediately, instead of waiting for the buffer to fill up or the stream to close.</li></ul><p><strong>Important Streams</strong></p><ul><li><strong>System.in</strong>(InputStream) →Receives standard input, typically from the keyboard.</li><li><strong>System.out</strong>(PrintStream) →Displays standard output, typically in the console.</li><li><strong>System.err</strong>(PrintStream) → Displays error output, typically in the console.</li></ul><h4>Reading image</h4><pre>import java.io.FileInputStream;<br>import java.io.FileOutputStream;<br>import java.io.IOException;<br><br>public class ImageCopy {<br>    public static void main(String[] args) {<br><br>        String source = &quot;photo.jpg&quot;;<br>        String destination = &quot;photo_copy.jpg&quot;;<br><br>        try (<br>            FileInputStream fis = new FileInputStream(source);<br>            FileOutputStream fos = new FileOutputStream(destination)<br>        ) {<br>            byte[] buffer = new byte[1024];<br>            int bytesRead;<br><br>            while ((bytesRead = fis.read(buffer)) != -1) {<br>                fos.write(buffer, 0, bytesRead);<br>            }<br><br>            System.out.println(&quot;Image copied successfully!&quot;);<br><br>        } catch (IOException e) {<br>            System.out.println(&quot;Error: &quot; + e.getMessage());<br>        }<br>    }<br>}</pre><pre>byte[] buffer = new byte[1024];</pre><p>Creates an array that can hold 1,024 bytes at a time.</p><pre>fos.write(buffer, 0, bytesRead);</pre><p>Writes only the bytes that were actually read, starting at index 0.</p><p>similar procedure for reading audio and video.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d402a2b0c141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Packages in java]]></title>
            <link>https://medium.com/@vignesh4485849/packages-in-java-91ed8f17c3ed?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/91ed8f17c3ed</guid>
            <category><![CDATA[types-of-package]]></category>
            <category><![CDATA[package]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 05:30:31 GMT</pubDate>
            <atom:updated>2026-10-23T05:30:31.294Z</atom:updated>
            <content:encoded><![CDATA[<p>In Java, packages are used to group related classes, interfaces, enums and sub package.</p><p>It helps to organize code, avoid naming conflicts and control access makes large applications easier to maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Dgs04XCulmusbEN557mmg.png" /></figure><h4>Types of packages in java</h4><p>There are primarily two types of packages in java,</p><ol><li><strong><em>User defined package</em></strong></li></ol><p>User defined packages are created by programmers to organize application specific classes and interfaces.</p><p><strong><em>2. Built in package</em></strong></p><p>Built in packages are provided by the java API. They contain common classes and interfaces for common programming task.</p><p>Some of common important built in packages are:</p><p><strong>java.lang : </strong>contains fundamental classes and interfaces that support core java function such as String, Math, System and Wrapper classes like Integer, Double and Boolean. This package is automatically imported.</p><p><strong>Java.io :</strong> contains class for supporting input/output operations.</p><p><strong>java.util</strong> : contains utility classes that implement data structures such as LinkedList, Dictionaries as wells as support for date and time operations.</p><p><strong>java.awt:</strong> awt stands for abstract window toolkit. Contains classes for implementing the components for graphical user interfaces like buttons, menu etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8aHAewpYqt95ErHfbEjeQ.jpeg" /><figcaption>Package types</figcaption></figure><p>Lets understand what happens when we write</p><pre>import java.util.ArrayList;</pre><p><strong><em>What is import?</em></strong></p><p>In Java, import tells java we want to use classes and interfaces without writing its full name.</p><p>without import, we have to use its full qualified name</p><pre>java.util.ArrayList&lt;String&gt; list=new java.util.ArrayList&lt;&gt;();</pre><p><strong><em>What is java?</em></strong></p><p>java is a <strong>top level package</strong> name.</p><p>Java organizes its built in classes into groups called packages.</p><p>For example :</p><ul><li>java.util</li><li>java.io</li><li>java.lang</li></ul><p><strong><em>What is util?</em></strong></p><p>A package containing useful class and tools.</p><p>util is short for utilities.</p><p><strong>what is ArrayList?</strong></p><p>ArrayList is a resizeable array that contains several used method to store and manipulate group of objects efficiently.</p><h4>Access Modifiers in java</h4><p>Access modifiers controls who can access a class, variable, method or constructor.</p><p>Java has four important access modifier those are,</p><ul><li><strong>public</strong>→ Accessible everywhere.</li><li><strong>private</strong> → Accessible only within the same class.</li><li><strong>protected</strong> →Accessible within same package(both subclass and non subclass) and subclass of other package.</li><li><strong>default </strong>→ Accessible within the same package(both subclass and non subclass). It is also called <strong>package private access</strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91ed8f17c3ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exception Handling In java]]></title>
            <link>https://medium.com/@vignesh4485849/exception-handling-in-java-422fedd51e7f?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/422fedd51e7f</guid>
            <category><![CDATA[exception]]></category>
            <category><![CDATA[exception-handling]]></category>
            <category><![CDATA[error-handling]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 08:01:21 GMT</pubDate>
            <atom:updated>2026-10-15T08:01:21.458Z</atom:updated>
            <content:encoded><![CDATA[<p>Exception handling is not about handling errors, It’s about how to save your application from some unconditional situation and showing a meaningful error message.</p><p>For instance, Imagine you are working in a bank application. If any errors occurs, while withdrawing money, we have to show a meaningful errors with error code and message. Otherwise user don’t know whats happening.</p><p>Similarly, while transferring money if we try to transfer more than our balance we have to show a meaningful error. These situations Exception Handling is a biggest asset to us.</p><p><strong><em>What is an Exception in java?</em></strong></p><p>In Java, an Exception is an unwanted or unexpected event, that disturbs the normal flow of the program during the program execution.</p><p><strong><em>What is an Exception Handling?</em></strong></p><p>Exception Handling is a mechanism, used to handle exceptional conditions that occur during the program execution.</p><p>It helps to prevent the program from terminating unexpectedly. It allows developers to provide appropriate recovery.</p><h3><strong>Java Exception Hierarchy</strong></h3><p>In Java, throwable has two direct subclasses: Exception and Error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDTUew8Q-K5BP0B1MIDDpw.png" /></figure><p><strong>Error: </strong>Error is a serious problem that occur system level failures. Programmers can’t do anything for this.</p><ul><li>Caused by JVM or System failures.</li><li>The program is unable to recover.</li></ul><p>Example:</p><ul><li>OutOfMemoryError</li><li>StackOverFlowError</li></ul><h4>Types of exception in java</h4><p>There are mainly two types of exception in java.</p><ol><li>Checked Exception</li><li>Unchecked Exception</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BIz9FuRlJ1M7zaabihbfg.png" /></figure><ol><li><strong>Checked Exception</strong></li></ol><p>It is checked by the compiler and must be caught or declared using throws keyword(The compiler requires you to catch or declare them).</p><p>2. <strong>Unchecked Exception</strong></p><p>It is a subclass of RuntimeException, It do not require handling or declaring them (Technically, Error types are also unchecked, but they are not exceptions).</p><h4><strong>Built in Exception</strong></h4><p>Built in exceptions are predefined and available in java library to handle runtime and compile errors.</p><p>Helps to handle the common errors and prevent program termination.</p><h4>User defined Exception</h4><p>A user-defined exception is an exception class created by developers to represent application specific or business specific error scenarios.</p><p>We can create our own exception by simply extending Exception class.</p><pre>public class InvalidAgeException extends Exception {<br>    public InvalidAgeException(String message) {<br>        super(message);<br>    }<br>}</pre><h4><strong>Exception handling keywords</strong></h4><ol><li><strong>try: </strong>try block contains code that might throw an exception, when an exception occurs, the control flow is transferred to the catch block.</li><li><strong>catch:</strong> catch block is used to catch the exception that is thrown from the associated try block.</li><li><strong>finally:</strong> finally is used to execute cleanup code after try-catch. It normally executes whether exception occur or not. Finally may not execute in cases like System.exit(), JVM crash and infinite loop before finally.</li><li><strong>throw:</strong> throw keyword is used to explicitly throw an exception from the method or block of code during program execution. It is followed by the Object of the throwable class or one of its subclasses.</li><li><strong>throws:</strong> throws keyword is used in a method definition to specify one or more exceptions that the method may throw during program execution. It informs the caller that the exception may need to be handled using try-catch or further using throws.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=422fedd51e7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lambda Expression in java]]></title>
            <link>https://medium.com/@vignesh4485849/lambda-expression-in-java-af6c3b50a846?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/af6c3b50a846</guid>
            <category><![CDATA[lambda-expressions]]></category>
            <category><![CDATA[lambda]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Wed, 07 Oct 2026 08:00:19 GMT</pubDate>
            <atom:updated>2026-10-07T08:00:19.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pUGOsntYhrIua3IJ3837AA.png" /></figure><p>It is a short way of writing the implementation of functional interface. Functional interface is an interface, a class with only one abstract method. It can also have multiple default and static methods.</p><p>It is introduced in java 8. Lambda requires functional interface.</p><p>It make code shorter, cleaner and easier to read, especially when working with collections and functional interface.</p><p><strong><em>Why do we need Lambda Expression?</em></strong></p><ol><li>Less code — We don’t need to write any complex code.</li><li>Better Readability — We can able to easily understand the logic.</li><li>Pass behaviour as a parameter — We can pass a piece of code to another method.</li></ol><p><strong><em>Lambda Expression and Lambda Block</em></strong></p><p>Syntax for lambda expression:</p><pre>(a,b)-&gt;a+b;</pre><p>Syntax for lambda block:</p><pre>(a,b)-&gt;{<br> int sum = Math.max(a, b);<br> return sum;<br>}</pre><p><strong><em>Lambda with no parameters</em></strong></p><pre>@FunctionalInterface<br>interface Message{<br>    void show();<br>}<br>public class Demo {<br>    public static void main(String[] args) {<br>        Message m=()-&gt; System.out.println(&quot;Hello world!&quot;);<br>        m.show();<br>    }<br>}<br>output:<br>Hello world!</pre><p><strong><em>Lambda with return values</em></strong></p><pre>@FunctionalInterface<br>interface Calculator{<br>    int add(int a,int b);<br>}<br>public class Demo {<br>    public static void main(String[] args) {<br>        Calculator c=(a,b)-&gt;a+b;<br>        System.out.println(c.add(10,20));;<br>    }<br>}<br>output:<br>30</pre><p><strong><em>Using lambda with finding odd/even:</em></strong></p><pre>@FunctionalInterface<br>interface NumberCheck{<br>    boolean checkEven(int a);<br>}<br>public class Demo {<br>    public static void main(String[] args) {<br>       NumberCheck c=(n)-&gt;n%2==0;<br>        System.out.println(c.checkEven(10));<br>    }<br>}<br>output:<br>true</pre><p><strong><em>Working with collections:</em></strong></p><p>Using lambda functions, we can easily work with collections and perfrom many operations such as forEach(), map() and removeIf().</p><p>They help us to write collections opreation in shorter and more readable way.</p><p><strong><em>Using forEach() Method:</em></strong></p><pre>public class Demo {<br>    public static void main(String[] args) {<br>        List&lt;String&gt; names= Arrays.asList(&quot;Vignesh&quot;,&quot;Linkesh&quot;,&quot;Eswar&quot;,&quot;Vadivel&quot;);<br>        names.forEach((name)-&gt; System.out.println(name.toUpperCase()));<br><br>        //Another way of printing elements<br>        names.forEach(System.out::println);<br>    }<br>}</pre><p>Equivalent Lamda:</p><pre>names.forEach((name)-&gt; System.out.println(name));</pre><p>Method Reference:</p><pre>names.forEach(System.out::println);</pre><p>The above one is called method reference, shorter way of writing lambda expression.</p><blockquote>For each element, call the println() method.</blockquote><p><strong><em>Using removeIf() method:</em></strong></p><pre>public class Demo {<br>    public static void main(String[] args) {<br>       List&lt;Integer&gt; nums=new ArrayList&lt;&gt;(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8));<br>       nums.removeIf((num)-&gt;num%2==0);<br>       System.out.println(nums);<br>    }<br>}</pre><p><strong><em>What is Stream() in Lambda Epression?</em></strong></p><p>Stream() is not a part of Lamda expression.</p><p>Stream() is a part of Java Stream API, and Lambda expreassion are commonly used with stream in java.</p><p><strong><em>Why do we need Stream()?</em></strong></p><p>Streams allows us to process the collection of elements, without creating any complex loops.</p><pre>public class Demo {<br>    public static void main(String[] args) {<br>       List&lt;Integer&gt; nums=new ArrayList&lt;&gt;(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8));<br>       nums.stream()<br>               .filter((num)-&gt;num%2==0)<br>               .map((num)-&gt;num*num)<br>               .forEach(System.out::println);<br>    }<br>} // This is also called as stream chaining.</pre><p>Explanation:</p><p>Filter() method helps to filter the elements based on the condition, In the above example even numbers are passed to the next phase of stream. Then we again processing the List element, using map() method we can transform elements and it returns the new Stream.</p><p>Finally we used forEach() method through iterate and print the elements in the stream.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af6c3b50a846" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generics in Java]]></title>
            <link>https://medium.com/@vignesh4485849/generics-in-java-18c844be27d7?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/18c844be27d7</guid>
            <category><![CDATA[java-generic]]></category>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[java-wildcards-explained]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Thu, 24 Sep 2026 05:15:24 GMT</pubDate>
            <atom:updated>2026-09-24T05:17:59.312Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lF_KDFPAYhIGPUkNH545Sg.png" /></figure><p><strong><em>Why Generics?</em></strong></p><p>Generics allows us to write classes, methods and interfaces that works with multiple data types, without having to specify the exact type in advance.</p><p>Generics only accept Wrapper class types (because of a process called type erasure) not primitives.</p><p><strong><em>key Features</em></strong></p><ul><li><strong>Code Reusability: </strong>We can use the same class or methods that works with different data types.</li><li><strong>Type Safety:</strong> It catches the errors at compile time instead of runtime.</li><li><strong>Elimination of Casting:</strong> It removes the explicit type casting when retrieving items.</li></ul><p><strong><em>Generic type Naming convention</em></strong></p><ul><li>E — Element (used in Collection)</li><li>K — Key (used in Map)</li><li>V — Value (used in Map)</li><li>T — Type</li><li>S, U, V — 2nd, 3rd, 4th types</li></ul><p><strong><em>Generic Method in Java</em></strong></p><p>Generic method is a method that works with different data types.</p><ol><li>Method with no return type</li></ol><pre>public class Demo {<br>    public static &lt;T&gt; void printValue(T value){<br>        System.out.println(&quot;Value : &quot;+value);<br>    }<br>    public static void main(String[] args) {<br>         printValue(10);  //T = Integer<br>         printValue(&quot;Vignesh&quot;);  //T = String<br>         printValue(10.3); //T = Double<br>    }<br>}<br><br>Output:<br><br>Value : 10<br>Value : Vignesh<br>Value : 10.3</pre><p>2. Method with return type</p><pre>public class Demo {<br>    public static&lt;T&gt; T returnValue(T value){<br>       return value;<br>    }<br>    public static void main(String[] args) {<br>        String name=returnValue(&quot;Vignesh&quot;);<br>        System.out.println(name);<br>        System.out.println(returnValue(10));<br>        System.out.println(returnValue(10.5));<br>    }<br>}<br>Output:<br>Vignesh<br>10<br>10.5</pre><h4><strong><em>Generic class in Java</em></strong></h4><p>Similarly generic class also that works with different types.</p><p>please first go through once the below code, then only you can able to understand Diamond operator and Type erasure.</p><p><strong><em>Diamond Operator &lt;&gt;</em></strong></p><p><em>Without Diamond operator :</em></p><pre>CustomArrayList&lt;String&gt; list = new CustomArrayList&lt;String&gt;();</pre><p>without diamond operator we have to write String twice.</p><p><em>With Diamond operator:</em></p><pre>CustomArrayList&lt;String&gt; list = new CustomArrayList&lt;&gt;();</pre><p>with diamond operator, java automatically identifies the type while the compile time.</p><h4>Type erasure</h4><p><strong><em>what is type erasure?</em></strong></p><p>Java use generic type information during compilation, but the generic type is automatically removed/erased from the compiled byte code. So runtime java don’t have any idea about T(type parameter).</p><p>Java asks, hey i don’t know any idea about type T, what it means. That’s why we used <strong>Object </strong>instead of type T.</p><p><strong><em>Why we need to use Object instead T?</em></strong></p><p>As we said before, java don’t have any idea about T at runtime. So we used Object, because object is a superclass of all reference types, so it can hold objects of different reference types.</p><pre>private T[] data;<br>data = new T[10];  // this is not allowed 🙅‍♀️ cause actual array creation happen at runtime.<br><br>//since T is erased and its actual type is not available on runtime we use Object<br><br>Object[] data= new Object[size];</pre><p><strong>Generic class example :</strong></p><pre>public class Demo {<br>    public static void main(String[] args) {<br>        CustomArrayList&lt;Integer&gt; list=new CustomArrayList&lt;&gt;(5);<br>        list.add(10);<br>        list.add(20);<br>        list.addFirst(5);<br>        list.printList();<br>        System.out.println(list.isFull());<br>        System.out.println(list.isEmpty());<br>    }<br>}</pre><pre>public class CustomArrayList&lt;T&gt;{<br>    private Object[] data;<br>    protected static final int DEFAULT_SIZE = 10;<br>    private int size=0;<br><br><br>    public CustomArrayList() {<br>        this(DEFAULT_SIZE);<br>    }<br>    public CustomArrayList(int size) {<br>        data = new Object[size];<br>    }<br><br>    public void add(T value){<br>        if(isFull()){<br>            doubleArray();<br>        }<br>      data[size++]=value;<br>    }<br>    public void addFirst(T value){<br>        if (isFull()) {<br>            doubleArray();<br>        }<br>        size++;<br>        for(int i=size-1;i&gt;0;i--){<br>            data[i]=data[i-1];<br>        }<br>        data[0]=value;<br>    }<br>    public T get(int index){<br>        return (T) data[index]; // Here we need to cast, cause data is Object[],<br>   // so data[index] is Object but we said return T, So thats we casted into T.<br>    }<br>    public void set(int index,T value){<br>        data[index]=value;<br>    }<br><br>    private void doubleArray(){<br>        Object[] array=new Object[data.length*2];<br>        for(int i=0;i&lt;data.length;i++){<br>            array[i]=data[i];<br>        }<br>        data=array;<br>    }<br>    public T deleteLast() throws Exception{<br>        if(isEmpty()){<br>            throw new Exception(&quot;Array is Emptyp&quot;);<br>        }<br>        return  (T) data[--size];<br>    }<br><br>    public boolean isEmpty(){<br>        return size==0;<br>    }<br>    public boolean isFull(){<br>        return size==data.length;<br>    }<br><br>    public void printList(){<br>        System.out.print(&quot;[&quot;);<br>        for(int i=0;i&lt;size;i++){<br>            if(i==size-1){<br>                System.out.print(data[i]);<br>            }<br>            else{<br>                System.out.print(data[i]+&quot;,&quot;);<br>            }<br>        }<br>        System.out.println(&quot;]&quot;);<br>    }<br>}</pre><pre>OUTPUT :<br>[5,10,20]<br>false<br>false</pre><p><strong>Wildcard </strong><strong><em>?</em> in Generics</strong></p><p>If you don’t know the exact generic type, we can use <em>? . </em>It accepts all the types.</p><p><em>?</em>which means <strong>unknown type</strong>.</p><p>For instance :</p><pre>List&lt;?&gt; list</pre><p><strong>Why do we need </strong><strong><em>?</em> ?</strong></p><p>suppose you have:</p><pre>List&lt;String&gt; names = new ArrayList&lt;&gt;();<br>List&lt;Integer&gt; numbers = new ArrayList&lt;&gt;();</pre><p>you want one method that accepts both.</p><pre>public void printList(List&lt;?&gt; list) {<br>    for (Object value : list) {// here Object is a parent class of all reference<br>        System.out.println(value);<br>    }<br>}</pre><p><strong>Important Limitation</strong></p><pre>List&lt;?&gt; list = new ArrayList&lt;String&gt;(); <br>list.add(&quot;Hello&quot;); // this is not allowed, cause java doesn&#39;t know <br>//what ? actually represents. </pre><h4>Upper Bounded Wildcards</h4><p>Sometimes we need to restrict some types and you only want to allow specific types like Number and its subclass type, that time we can use upper bounded wildcard.</p><pre>List&lt;? extends Number&gt;</pre><p>This means List can contain Number and it subclass like Integer, Double, Float and Long.</p><pre>public class Demo {<br><br>    public static void printNumbers(List&lt;? extends Number&gt; numbers) {<br>        for (Number number : numbers) {<br>            System.out.println(number);<br>        }<br>    }<br><br>    public static void main(String[] args) {<br><br>        List&lt;Integer&gt; integers = Arrays.asList(10, 20, 30);<br>        List&lt;Double&gt; doubles = Arrays.asList(10.5, 20.5, 30.5);<br><br>        printNumbers(integers);<br>        printNumbers(doubles);<br>    }<br>}<br>OUTPUT:<br>10<br>20<br>30<br>10.5<br>20.5<br>30.5</pre><h4>Lower Bounded Wildcards</h4><p>For lower bounded wildcard we use <strong>super</strong> keyword.</p><pre>List&lt;? super Integer&gt;</pre><p>This means the List must be Integer and its superclass of Integer.</p><pre>Object<br>   ↑<br>Number<br>   ↑<br>Integer<br><br>// So these below are only allowed.<br>List&lt;Integer&gt;    <br>List&lt;Number&gt;     <br>List&lt;Object&gt;   <br><br>//these below are not allowed.<br>List&lt;Double&gt;    <br>List&lt;String&gt;   </pre><pre>public class Demo {<br>    public static void addNumbers(List&lt;? super Integer&gt; numbers) {<br>        numbers.add(10);<br>        numbers.add(20);<br>        numbers.add(30);<br><br>        System.out.println(numbers);<br>    }<br><br>    public static void main(String[] args) {<br><br>        List&lt;Integer&gt; integers = new ArrayList&lt;&gt;();<br>        addNumbers(integers);<br>    }<br>}<br>OUTPUT:<br>[10, 20, 30]</pre><p><strong>Producer and Consumer</strong></p><p>While working with Wildcards we need to understand <strong>what is producer? </strong>and <strong>what is consumer?</strong></p><ul><li>Producer — means produce data, give some data. In programming we print something, which means we are reading the data(read panrathu) not write. We use <strong>extends(</strong>List&lt;? extends Number&gt;) keyword.</li><li>Consumer — means consumes/accepts data, used to write the data. Here we use <strong>super</strong> keyword. We use <strong>add method</strong> to write the data in array.</li></ul><ol><li>Producer — extends</li></ol><p>As we said, producer is something that produces/gives us values.</p><pre>Producer → ? extends <br>            ↓ <br>           READ</pre><p>For instance:</p><pre>public static void printNumbers(List&lt;? extends Number&gt; numbers) { <br>     for (Number number : numbers) { <br>          System.out.println(number); <br>     }<br>}</pre><p>here list is producer cause we are getting the values. We are mainly reading the data.</p><p>2. Consumer — super</p><p>Consumer is something that accepts/receives values.</p><pre>Consumer → ? super <br>            ↓<br>       ADD / WRITE</pre><p>For instance :</p><pre>public static void addNumbers(List&lt;? super Integer&gt; numbers) {<br>    numbers.add(10);<br>    numbers.add(20);<br>}</pre><p>Here we used add method to write the data in the list.</p><p><strong><em>Easy way to remember</em></strong></p><p>PECS</p><ul><li>Producer — Extends</li><li>Consumer — Super</li></ul><p>If you found this blog is useful to you, please don’t forget to hit the like button. That will motivates me to write more blogs like this.</p><p>நன்றி 🙏😁…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18c844be27d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BigInteger and BigDecimal in Java]]></title>
            <link>https://medium.com/@vignesh4485849/biginteger-and-bigdecimal-in-java-9f4f0da2bd1d?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f4f0da2bd1d</guid>
            <category><![CDATA[random]]></category>
            <category><![CDATA[bigdecimal]]></category>
            <category><![CDATA[biginteger]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 07:47:25 GMT</pubDate>
            <atom:updated>2026-09-23T07:47:25.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BC4qedXgcPbJFfRF-Azvg.png" /></figure><h3>BigInteger</h3><p>BigInteger class in java is a part of java.math package. It is used to handle larger numbers, which exceeds the long.</p><p>BigIntegers are immutable in java.</p><p>So BigInteger class is used to perform mathematical operations that involves very large integers that exceeds the limits of primitive data types.</p><p><strong><em>why do we need BigInteger?</em></strong></p><p>In java primitive data types like short, int and long have the fixed size limits. We can’t store larger number which is greater then long, so java provides BigInteger and BigDecimal to handle large numbers.</p><p><strong><em>Range of BigInteger</em></strong></p><pre>-2^Integer.MAX_VALUE(exclusive) TO 2^Integer.MAX_VALUE(exclusive)</pre><p><strong><em>Different ways to create BigInteger in java</em></strong></p><ol><li>Using Built In Constants</li></ol><p>If you only need 0,1 and 10 BigInteger provides pre-defined constants.</p><pre>BigInteger zero = BigInteger.ZERO; // 0<br>BigInteger one  = BigInteger.ONE;  // 1<br>BigInteger ten  = BigInteger.TEN;  // 10</pre><p>2. Using Static Factory Method</p><p>For numbers that can fit into a primitive long, we can use BigInteger.valueOf(long val).</p><pre>BigInteger fromLong = BigInteger.valueOf(123456789L);<br>BigInteger fromInt  = BigInteger.valueOf(42); // int is auto-promoted to long</pre><p>3. Using the String Constructor</p><p>If the number that exceeds the primitive long, we use this method to create a larger BigInteger.</p><pre>BigInteger largeNum = new BigInteger(&quot;987654321012345678901234567890&quot;); <br><br>BigInteger hexNum = new BigInteger(&quot;A1C2F&quot;, 16); // Hexadecimal string<br>BigInteger binNum = new BigInteger(&quot;11010111&quot;, 2); // Binary string<br><br>OUTPUT:<br>987654321012345678901234567890<br>662575<br>215</pre><p>4. Using a Byte Array</p><pre>byte[] byteArray = new byte[]{1, 2, 3};<br>BigInteger fromBytes = new BigInteger(byteArray);<br><br>// Alternatively, specify the sign explicitly: -1 for negative, 0 for zero, 1 for positive<br>BigInteger fromSignMag = new BigInteger(1, byteArray); </pre><p><strong><em>Methods in BigInteger</em></strong></p><p>There are lots of methods in BigInteger class we will look into some common methods</p><pre>import java.math.BigInteger;<br><br>public class BigIntegerMethods {<br><br>    public static void main(String[] args) {<br><br>        BigInteger a = new BigInteger(&quot;48&quot;);<br>        BigInteger b = new BigInteger(&quot;18&quot;);<br><br><br>        // =====================================================<br>        // 1. ARITHMETIC METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;===== ARITHMETIC =====&quot;);<br><br>        // Addition<br>        System.out.println(&quot;add()              : &quot; + a.add(b));<br><br>        // Subtraction<br>        System.out.println(&quot;subtract()         : &quot; + a.subtract(b));<br><br>        // Multiplication<br>        System.out.println(&quot;multiply()         : &quot; + a.multiply(b));<br><br>        // Division<br>        System.out.println(&quot;divide()           : &quot; + a.divide(b));<br><br>        // Remainder<br>        System.out.println(&quot;remainder()        : &quot; + a.remainder(b));<br><br>        // Power<br>        System.out.println(&quot;pow()              : &quot; + a.pow(2));<br><br><br>        // =====================================================<br>        // 2. COMPARISON METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== COMPARISON =====&quot;);<br>        <br>        //-1  → a &lt; b<br>        // 0  → a == b<br>        // 1  → a &gt; b<br><br>        // compareTo()<br>        System.out.println(&quot;compareTo()        : &quot; + a.compareTo(b));<br><br>        // equals()<br>        System.out.println(&quot;equals()           : &quot; + a.equals(b));<br><br>        // min()<br>        System.out.println(&quot;min()              : &quot; + a.min(b));<br><br>        // max()<br>        System.out.println(&quot;max()              : &quot; + a.max(b));<br><br><br>        // =====================================================<br>        // 3. CONVERSION METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== CONVERSION =====&quot;);<br><br>        BigInteger number = new BigInteger(&quot;123456&quot;);<br><br>        // Convert to int<br>        int intValue = number.intValue();<br>        System.out.println(&quot;intValue()         : &quot; + intValue);<br><br>        // Convert to long<br>        long longValue = number.longValue();<br>        System.out.println(&quot;longValue()        : &quot; + longValue);<br><br>        // Convert to double<br>        double doubleValue = number.doubleValue();<br>        System.out.println(&quot;doubleValue()      : &quot; + doubleValue);<br><br>        // Convert to String<br>        String stringValue = number.toString();<br>        System.out.println(&quot;toString()         : &quot; + stringValue);<br><br>        // Convert to byte array<br>        byte[] bytes = number.toByteArray();<br>        System.out.print(&quot;toByteArray()      : &quot;);<br><br>        for (byte value : bytes) {<br>            System.out.print(value + &quot; &quot;);<br>        }<br><br>        System.out.println();<br><br><br>        // =====================================================<br>        // 4. BITWISE METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== BITWISE =====&quot;);<br><br>        BigInteger x = new BigInteger(&quot;10&quot;);<br>        BigInteger y = new BigInteger(&quot;6&quot;);<br><br>        // Bitwise AND<br>        System.out.println(&quot;and()              : &quot; + x.and(y));<br><br>        // Bitwise OR<br>        System.out.println(&quot;or()               : &quot; + x.or(y));<br><br>        // Bitwise XOR<br>        System.out.println(&quot;xor()              : &quot; + x.xor(y));<br><br>        // Shift bits to left<br>        System.out.println(&quot;shiftLeft()        : &quot; + x.shiftLeft(2));<br><br>        // Shift bits to right<br>        System.out.println(&quot;shiftRight()       : &quot; + x.shiftRight(1));<br><br><br>        // =====================================================<br>        // 5. MATHEMATICAL METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== MATHEMATICAL =====&quot;);<br><br>        BigInteger p = new BigInteger(&quot;48&quot;);<br>        BigInteger q = new BigInteger(&quot;18&quot;);<br><br>        // Greatest Common Divisor<br>        System.out.println(&quot;gcd()              : &quot; + p.gcd(q));<br><br>        // Modulo<br>        System.out.println(&quot;mod()              : &quot; +<br>                p.mod(BigInteger.valueOf(5)));<br><br>        // Modular exponentiation<br>        System.out.println(&quot;modPow()           : &quot; +<br>                p.modPow(BigInteger.valueOf(2),<br>                        BigInteger.valueOf(5)));<br><br>        // Modular multiplicative inverse<br>        BigInteger inverse = BigInteger.valueOf(3)<br>                .modInverse(BigInteger.valueOf(7));<br><br>        System.out.println(&quot;modInverse()       : &quot; + inverse);<br><br>        // Check whether number is probably prime<br>        BigInteger primeNumber = new BigInteger(&quot;17&quot;);<br><br>        System.out.println(&quot;isProbablePrime()  : &quot; +<br>                primeNumber.isProbablePrime(100));<br><br><br>        // =====================================================<br>        // 6. SIGN &amp; BIT INFORMATION<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== SIGN &amp; BIT INFORMATION =====&quot;);<br><br>        BigInteger positive = new BigInteger(&quot;100&quot;);<br><br>        // Sign<br>        System.out.println(&quot;signum()           : &quot; +positive.signum());<br><br>        // Number of bits required<br>        System.out.println(&quot;bitLength()        : &quot; +positive.bitLength());<br><br>        // Number of 1-bits<br>        System.out.println(&quot;bitCount()         : &quot; +positive.bitCount());<br><br>        // Position of lowest set bit<br>        System.out.println(&quot;getLowestSetBit()  : &quot; +positive.getLowestSetBit());<br>    }<br>}</pre><pre>OUTPUT<br><br>===== ARITHMETIC =====<br>add()              : 66<br>subtract()         : 30<br>multiply()         : 864<br>divide()           : 2<br>remainder()        : 12<br>pow()              : 2304<br><br>===== COMPARISON =====<br>compareTo()        : 1<br>equals()           : false<br>min()              : 18<br>max()              : 48<br><br>===== CONVERSION =====<br>intValue()         : 123456<br>longValue()        : 123456<br>doubleValue()      : 123456.0<br>toString()         : 123456<br>toByteArray()      : 1 -30 64 <br><br>===== BITWISE =====<br>and()              : 2<br>or()               : 14<br>xor()              : 12<br>shiftLeft()        : 40<br>shiftRight()       : 5<br><br>===== MATHEMATICAL =====<br>gcd()              : 6<br>mod()              : 3<br>modPow()           : 4<br>modInverse()       : 5<br>isProbablePrime()  : true<br><br>===== SIGN &amp; BIT INFORMATION =====<br>signum()           : 1<br>bitLength()        : 7<br>bitCount()         : 3<br>getLowestSetBit()  : 2</pre><h4><strong>BigDecimal</strong></h4><p>The BigDecimal class in java represents immutable, It can store decimal with very high precision. Much more than float and double.</p><p><strong><em>BigDecimal Methods</em></strong></p><pre>import java.math.BigDecimal;<br>import java.math.RoundingMode;<br><br>public class BigDecimalMethods {<br><br>    public static void main(String[] args) {<br><br>        BigDecimal a = new BigDecimal(&quot;100.50&quot;);<br>        BigDecimal b = new BigDecimal(&quot;20.25&quot;);<br><br><br>        // =====================================================<br>        // 1. ARITHMETIC METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;===== ARITHMETIC =====&quot;);<br><br>        System.out.println(&quot;add()              : &quot; + a.add(b));<br><br>        System.out.println(&quot;subtract()         : &quot; + a.subtract(b));<br><br>        System.out.println(&quot;multiply()         : &quot; + a.multiply(b));<br><br>        System.out.println(&quot;divide()           : &quot; +<br>                a.divide(b, 2, RoundingMode.HALF_UP));<br><br>        System.out.println(&quot;remainder()        : &quot; + a.remainder(b));<br><br>        System.out.println(&quot;divideAndRemainder():&quot;);<br><br>        BigDecimal[] result = a.divideAndRemainder(b);<br><br>        System.out.println(&quot;  Quotient         : &quot; + result[0]);<br>        System.out.println(&quot;  Remainder        : &quot; + result[1]);<br><br>        System.out.println(&quot;pow()              : &quot; + a.pow(2));<br><br>        System.out.println(&quot;negate()           : &quot; + a.negate());<br><br>        System.out.println(&quot;abs()              : &quot; +<br>                new BigDecimal(&quot;-100.50&quot;).abs());<br><br><br>        // =====================================================<br>        // 2. COMPARISON METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== COMPARISON =====&quot;);<br><br>        System.out.println(&quot;compareTo()        : &quot; + a.compareTo(b));<br><br>        System.out.println(&quot;equals()           : &quot; + a.equals(b));<br><br>        System.out.println(&quot;min()              : &quot; + a.min(b));<br><br>        System.out.println(&quot;max()              : &quot; + a.max(b));<br><br><br>        // =====================================================<br>        // 3. ROUNDING &amp; PRECISION<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== ROUNDING &amp; PRECISION =====&quot;);<br><br>        BigDecimal number = new BigDecimal(&quot;123.456789&quot;);<br><br>        System.out.println(&quot;Original            : &quot; + number);<br><br>        System.out.println(&quot;setScale()          : &quot; +<br>                number.setScale(2, RoundingMode.HALF_UP));<br><br>        System.out.println(&quot;round()             : &quot; +<br>                number.round(<br>                        new java.math.MathContext(5)));<br><br>        System.out.println(&quot;precision()         : &quot; +<br>                number.precision());<br><br>        System.out.println(&quot;scale()             : &quot; +<br>                number.scale());<br><br><br>        // =====================================================<br>        // 4. CONVERSION METHODS<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== CONVERSION =====&quot;);<br><br>        BigDecimal value = new BigDecimal(&quot;12345.67&quot;);<br><br>        System.out.println(&quot;intValue()          : &quot; +<br>                value.intValue());<br><br>        System.out.println(&quot;longValue()         : &quot; +<br>                value.longValue());<br><br>        System.out.println(&quot;floatValue()        : &quot; +<br>                value.floatValue());<br><br>        System.out.println(&quot;doubleValue()       : &quot; +<br>                value.doubleValue());<br><br>        System.out.println(&quot;toBigInteger()      : &quot; +<br>                value.toBigInteger());<br><br>        BigDecimal exactValue = new BigDecimal(&quot;12345&quot;);<br><br>        System.out.println(&quot;toBigIntegerExact() : &quot; +<br>                exactValue.toBigIntegerExact());<br><br>        System.out.println(&quot;toString()          : &quot; +<br>                value.toString());<br><br><br>        // =====================================================<br>        // 5. SIGN &amp; VALUE<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== SIGN &amp; VALUE =====&quot;);<br><br>        BigDecimal positive = new BigDecimal(&quot;100.50&quot;);<br><br>        System.out.println(&quot;signum()            : &quot; +<br>                positive.signum());<br><br>        System.out.println(&quot;unscaledValue()     : &quot; +<br>                positive.unscaledValue());<br><br>        System.out.println(&quot;scaleByPowerOfTen() : &quot; +<br>                positive.scaleByPowerOfTen(2));<br><br><br>        // =====================================================<br>        // 6. DECIMAL POINT MOVEMENT<br>        // =====================================================<br><br>        System.out.println(&quot;\n===== DECIMAL POINT MOVEMENT =====&quot;);<br><br>        BigDecimal decimal = new BigDecimal(&quot;123.45&quot;);<br><br>        System.out.println(&quot;Original            : &quot; + decimal);<br><br>        System.out.println(&quot;movePointLeft()     : &quot; +<br>                decimal.movePointLeft(2));<br><br>        System.out.println(&quot;movePointRight()    : &quot; +<br>                decimal.movePointRight(2));<br><br>        BigDecimal trailing =<br>                new BigDecimal(&quot;123.45000&quot;);<br><br>        System.out.println(&quot;Before removing zeros : &quot; +<br>                trailing);<br><br>        System.out.println(&quot;stripTrailingZeros()  : &quot; +<br>                trailing.stripTrailingZeros());<br><br>        System.out.println(&quot;ulp()               : &quot; +<br>                decimal.ulp());<br>    }<br>}</pre><pre>OUTPUT<br>===== ARITHMETIC =====<br>add()              : 120.75<br>subtract()         : 80.25<br>multiply()         : 2035.1250<br>divide()           : 4.96<br>remainder()        : 19.50<br>divideAndRemainder():<br>  Quotient         : 4<br>  Remainder        : 19.50<br>pow()              : 10100.2500<br>negate()           : -100.50<br>abs()              : 100.50<br><br>===== COMPARISON =====<br>compareTo()        : 1<br>equals()           : false<br>min()              : 20.25<br>max()              : 100.50<br><br>===== ROUNDING &amp; PRECISION =====<br>Original            : 123.456789<br>setScale()          : 123.46<br>round()             : 123.46<br>precision()         : 9<br>scale()             : 6<br><br>===== CONVERSION =====<br>intValue()          : 12345<br>longValue()         : 12345<br>floatValue()        : 12345.67<br>doubleValue()       : 12345.67<br>toBigInteger()      : 12345<br>toBigIntegerExact() : 12345<br>toString()          : 12345.67<br><br>===== SIGN &amp; VALUE =====<br>signum()            : 1<br>unscaledValue()     : 10050<br>scaleByPowerOfTen() : 10050<br><br>===== DECIMAL POINT MOVEMENT =====<br>Original            : 123.45<br>movePointLeft()     : 1.2345<br>movePointRight()    : 12345<br>Before removing zeros : 123.45000<br>stripTrailingZeros()  : 123.45<br>ulp()               : 0.01</pre><h4>Random class in java</h4><p>Random class in java is used to generate random numbers. It is thread safe.</p><pre>import java.util.Random;<br><br>public class RandomExample {<br><br>    public static void main(String[] args) {<br><br>        Random random = new Random();<br><br>        // Generate a random integer<br>        int number = random.nextInt();<br><br>        System.out.println(&quot;Random number: &quot; + number);<br><br>        // Generate a random integer from 0 to 99<br>        int number1 = random.nextInt(100);<br><br>        System.out.println(&quot;Random number (0-99): &quot; + number1);<br><br>        // Generate a random double between 0.0 and 1.0<br>        double number2 = random.nextDouble();<br><br>        System.out.println(&quot;Random double: &quot; + number2);<br><br>        // Generate a random boolean<br>        boolean value = random.nextBoolean();<br><br>        System.out.println(&quot;Random boolean: &quot; + value);<br>    }<br>}</pre><pre>OUTPUT<br><br>Random number: 816627786<br>Random number (0-99): 65<br>Random double: 0.24825380542343833<br>Random boolean: false</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f4f0da2bd1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strings In Java]]></title>
            <link>https://medium.com/@vignesh4485849/strings-in-java-44e478e69b96?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/44e478e69b96</guid>
            <category><![CDATA[string]]></category>
            <category><![CDATA[string-in-java]]></category>
            <category><![CDATA[stirngbuilder]]></category>
            <category><![CDATA[stringbuffer]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 15:07:19 GMT</pubDate>
            <atom:updated>2026-10-10T04:27:56.919Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SLVVa_8FQkzj2kLVUApauA.png" /></figure><p>In java, String is an Object used to store sequence of characters. String also is a class provided by Java, so it is a reference type.</p><p>Strings (String literals) are stored in special memory called String Constant Pool. If the same literal already exists in the pool, Java reuses the existing String object instead of creating another one.</p><h3><strong>Why Strings are immutable in java?</strong></h3><p>Strings are immutable for security and memory efficiency. So whenever we change the existing string, it actually creates a new Object in java.</p><p>So inoreder to overcome this we have StringBuffer and StringBuilder. We will detaily look that into this blog.</p><h3><strong>Different ways to create Strings in java</strong></h3><p>There are two ways of we can create Strings in java,</p><ol><li><strong>String Literal</strong></li></ol><p>Basically String literal is a sequence of characters enclosed with double quotes. For memory efficiency, String literals are stored in special memory called String Constant Pool(SCP).</p><p>Example,</p><pre>String str=&quot;Joy boy&quot;;</pre><p><strong>2. Using new keyword</strong></p><p>Using new keyword, we can also create strings in java but, it is completly different from String literals. When we use new key word, the strings are created inside the heap not inside the String Constant Pool.</p><p>Example,</p><pre>String str=new String(&quot;Vignesh&quot;);</pre><h3><strong>How Strings are stored in java memory?</strong></h3><p>Strings are stored in special memory called String Constant Pool. Which is located inside of the heap. lets understand, why string is stored in string constant pool through small program.</p><pre>public class Demo {<br>    public static void main(String[] args) {<br>        String name=&quot;Vignesh&quot;;<br>        String str=&quot;Vignesh&quot;;<br>        System.out.println(&quot;Name : &quot;+name);<br>        System.out.println(&quot;Str  : &quot;+str);<br>        System.out.println(str==name);<br>        name=&quot;Ram&quot;;<br>        System.out.println(&quot;Name : &quot;+name);<br>        System.out.println(&quot;Str  : &quot;+str);<br>        System.out.println(str==name);<br>    }<br>}</pre><pre>OUTPUT<br>Name : Vignesh<br>Str  : Vignesh<br>true<br>Name : Ram<br>Str  : Vignesh<br>false</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*eP4AhPGeedunrupxW4Im7A.png" /></figure><p>name is a reference variable stored in the stack memory, and it refers to a String object stored in the heap memory. The String literal “Vignesh” is stored in the <strong>String Constant Pool (SCP)</strong>, which is part of the heap in modern JVM implementations.</p><p>Here both name and str is pointing to the same Object inside the SCP. So when we try to change name into something else like “Ram”, it only creates new object inside the SCP then, name variable is pointing to “Ram”. This is why Strings are immutable in java.</p><p>For instance, Imagine you are working in a big project, two users names are similar like “Vignesh”. If one user want to change their name into “Ram” if it is not immutable this also affects the another user. So this why strings are immutable in java.</p><p>Both name and str initially pointing to the same value “Vignesh”. When we change the value of name into “Ram”, java creates the new Object inside the heap.</p><p>If any String reference variable is not pointing to an object, that object will be automatically removed by the Garbage Collector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyPHZnv_ImpYuOCp33ss_Q.png" /></figure><p><strong>Using new key word</strong></p><p>When we use new keyword to create a String Object, It creates the new object outside the SCP but inside the Heap. So when we used to == compare the values it returns false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8yknt2R91wAXiBAJku5Dg.jpeg" /></figure><h3><strong>.equals() vs == in java</strong></h3><ol><li><strong>.equals()</strong></li></ol><p>In java, .equals() is a method in String class that compares the content of the two String object. So use this method, when you want to compare the content(values).</p><p><strong>2. ==</strong></p><p>== compares the references and checks whether both references refer to the same object.</p><pre>public class Demo {<br>    public static void main(String[] args) {<br>        String name = &quot;Vignesh&quot;;<br>        String str = new String(&quot;Vignesh&quot;);<br>        System.out.println(&quot;Using .equals() : &quot; + name.equals(str));<br>        System.out.println(&quot;Using ==        : &quot; + (name == str));<br>    }<br>}</pre><pre>Output<br>Using .equals() : true<br>Using ==        : false</pre><h3><strong>StringBuilder and StringBuffer in java</strong></h3><p>StringBuilder and StringBuffer are classes, which helps to create mutable sequence of strings Object in java. StringBuilder and StringBuffer objects are stored in the <strong>heap</strong>. Compare with String it is very fast, when a String is modified, it creates a new String Object cause String is immutable.</p><p>StringBuilder and StringBuffer both have similar methods for modifying Strings. But StringBuilder is not thread safe, so it is faster than the StringBuffer. StringBuffer is thread safe (it executes the operations synchronously) because its methods are synchronized.</p><h4><strong>Different Ways to create StringBuilder Object in Java</strong></h4><ol><li><strong>Using default constructor (StringBuilder()):</strong></li></ol><p>Creates an empty StringBuilder with default capacity of size 16.<br>Example,</p><pre>StringBuilder sb = new StringBuilder();  //default size 16</pre><p><strong>2. Using initial capacity (StringBuilder(10)) :</strong></p><p>Creates a new empty StringBuilder with pre-allocated capacity of some size using new StringBuilder(10).</p><pre>StringBuilder sb = new StringBuilder(10);  </pre><p><strong>3. Using initial String (StringBuilder(“Hello”)):</strong></p><p>new StringBuilder(“Hello”) has an initial capacity of 16 + length of the String, so for “Hello” the capacity is <strong>21</strong></p><pre>StringBuilder sb = new StringBuilder(&quot;Hello&quot;); //capcity is 21</pre><h4><strong>Methods in StringBuider and StringBuffer</strong></h4><p>StringBuilder and StringBuffer both have similar methods for modifying Strings.</p><p><strong>append() : </strong>used to add the String at the end of the StringBuilder.</p><pre>sb.append(&quot;Hello&quot;);</pre><p><strong>Insert(): </strong>used to insert a text at the specific position</p><pre>sb.insert(0, &quot;Hi &quot;);</pre><p><strong>replace(): </strong>it replaces characters in a specified range</p><pre>sb.replace(0, 5, &quot;Java&quot;);</pre><p><strong>delete(): </strong>Used to delete characters from the specified start index to the specified end index.</p><pre>sb.delete(0,2);</pre><p><strong>deleteCharAt(): </strong>used to delete one specific character in the Builder</p><pre>sb.deleteCharAt(2);</pre><p><strong>reverse(): </strong>reverse() method is used to reverse the String</p><pre>sb.reverse();</pre><p><strong>charAt(): </strong>used to get single character of a specified index</p><pre>sb.charAt(0);</pre><p><strong>setCharAt(): </strong>used to change single character of a specified index</p><pre>sb.setCharAt(0, &#39;J&#39;);</pre><p><strong>length(): </strong>It returns the number of characters in the string</p><pre>sb.length();</pre><p><strong>capacity():</strong> It returns the current capacity</p><pre>sb.capacity();</pre><p><strong>indexOf(): </strong>It finds the first occurence and return the index</p><pre>sb.indexOf(&quot;Java&quot;);</pre><p><strong>lastIndexOf(): </strong>It finds the last occurence and return the index</p><pre>sb.lastIndexOf(&quot;Java&quot;);</pre><p><strong>toString(): </strong>Used to convert builder into String</p><pre>String str1=sb.toString(); <br>String str2=String.valueOf(sb); // this also used convert builder into String</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44e478e69b96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vehicle Rental Management System]]></title>
            <link>https://medium.com/@vignesh4485849/vehicle-rental-management-system-4875c74ca609?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4875c74ca609</guid>
            <category><![CDATA[java-relation]]></category>
            <category><![CDATA[composition]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 00:15:31 GMT</pubDate>
            <atom:updated>2026-09-18T00:15:31.401Z</atom:updated>
            <content:encoded><![CDATA[<p>The Vehicle Rental Management System is a Java program. It is used to demonstrate IS-A and HAS-A relationships.</p><p>The code is in the Github. So please <a href="https://github.com/Vignesh-T21/MentarBridge-practiceQuestions/tree/main/src/main/java/com/relation">Click here</a>.</p><p>In this project, we have different vehicle types like <strong>Car, Bike, and Truck</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4J1sup7tNf_LBySo_eEtg.png" /></figure><h3>IS-A Relationship</h3><p>IS-A relationship is created using inheritance. Here, Car, Bike, and Truck extend the Vehicles class.</p><ul><li>Car IS-A Vehicle</li><li>Bike IS-A Vehicle</li><li>Truck IS-A Vehicle</li></ul><p>The Vehicle class contains common details like vehicle number, brand, model, and rent per day.</p><p>Each vehicle class also has its own extra property. For example, Car has number of doors, Bike has engine capacity, and Truck has load capacity.</p><h3>HAS-A Relationship</h3><p>HAS-A relationship means one class contains an object of another class as a member variable.</p><p>In this project, Customer contains an Address object. <strong>Customer HAS-A Address</strong>. Also, Rental contains a Customer object and a Vehicle object.</p><ul><li>Rental HAS-A Customer</li><li>Rental HAS-A Vehicle</li></ul><p>The objects are created using new and passed to the other class through the constructor.</p><h3>Polymorphism</h3><p>Polymorphism is also demonstrated in this project.</p><p>For Instance:</p><pre>Vehicle vehicle = new Car(...);</pre><p>Here, the reference is Vehicle, but the actual object is Car.We can also create Bike and Truck objects using the Vehicle reference.</p><p>When we call displayVehicleDetails(), the overridden method of the actual vehicle type is executed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4875c74ca609" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Memory Model Architecture]]></title>
            <link>https://medium.com/@vignesh4485849/java-memory-model-architecture-318b974f2289?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/318b974f2289</guid>
            <category><![CDATA[memory-stack]]></category>
            <category><![CDATA[java-memory-model]]></category>
            <category><![CDATA[runtime-data-area]]></category>
            <category><![CDATA[jvm-memory]]></category>
            <category><![CDATA[heap-memory]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 10:41:15 GMT</pubDate>
            <atom:updated>2026-08-07T10:41:15.123Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kaqqIntIrF8vuPHNdmsoA.png" /></figure><p>Before we deep dive into java memory model architecture, if you don’t know what is java and how it works? please <a href="https://medium.com/@vignesh4485849/introduction-to-java-2c387cac13d1">click here</a>.</p><p>Before we start a small recap of last session,</p><p>Whenever we wrote a java code we stored with .java extension which is in human readable format. Then JavaC is a java compiler(translator) which translates the human readable code into byteCode which has the extension .class, this code only understand by the machine, then <strong>Execution Engine</strong> inside in JVM converts byte code into machine code.</p><p>Have you ever think about why we need JavaC(java compiler)? Imagine you are going to a hotel and you are ordering some foods but the waiter don’t know your language. So you need a translator. Like here machines don’t know human (human readable format) code, so java compiler translates to bytecode.</p><p>Class loader which loads all the byte code . Then Execution engine in inside the JVM converts byte code into machine code. JDK is used to develop and run Java programs. It includes the JRE. If you only want to run a Java program, the JRE is sufficient. JRE is platform dependent. JRE provide the environment for only run the code.</p><blockquote>JDK and JRE platform dependent</blockquote><pre>Bytecode<br>      │<br>Class Loader<br>      │<br>Bytecode Verifier<br>      │<br>Execution Engine<br>      │<br> ┌──────────────┐<br> │ Interpreter  │<br> │      or      │<br> │   JIT        │<br> └──────────────┘<br>      │<br>Machine Code</pre><p>In java every variables, methods and class are stored in different memory areas. In this blog we are going to mainly focus, how java memory works and where the data is actually stored.</p><h3>Runtime Data Area</h3><p>At runtime, JVM creates different memory area to execute a program. These memory areas called Runtime Data Areas.</p><p>There are mainly five data areas, and they are categorized into two types based on how they shared and managed across threads.</p><ol><li>Thread shared Memory area( created once per JVM).</li><li>Thread private Memory area( created once per thread).</li></ol><p><strong>Thread is a small unit of execution or flow of execution.</strong></p><h3>1. Thread shared memory area</h3><p>These are created when JVM starts, and are shared across all threads running in the application.</p><h4>i. Method area</h4><p>stores,</p><ul><li>class metaData</li><li>static variables</li><li>method information</li><li>byteCode</li><li>constant pool</li></ul><p>why shared,</p><p>There is only one copy of a class, if 1000 MemoryArchitecture Object is created like</p><p>MemoryArchitecture (obj1), MemoryArchitecture (obj2) …. MemoryArchitecture (obj1000)</p><p>JVM doesn’t create 1000 copies of class, It creates only one copy of class inside the MethodArea.</p><p>All class Objects are use that class definition.</p><h4>ii. Heap Memory (Largest Memory Area)</h4><ul><li>It stores, Objects, Arrays and Instance (Dynamic, non-static, object) variables.</li><li>Heap memory allocated at runtime</li><li>If two threads need the same object, both threads can access it. That why it is thread shared.</li></ul><pre>Thread 1<br>      \<br>       \<br>        ---&gt; Heap Object<br>       /<br>Thread 2</pre><h4>Garbage Collector :</h4><p>Objects that are no longer referenced are automatically removed by the Garbage Collector (GC). But GC not inside Heap, it is a part of JVM.</p><h3>2. Thread Private Memory are</h3><p>These areas are created individually whenever a new thread is spawned. Thread private area ensures each thread has its own isolated execution context (own private workspace).</p><h4>i. Java Stack</h4><p>stores,</p><ul><li>Method execution frames</li><li>Method parameters</li><li>Local variables</li><li>Object reference</li></ul><p>Whenever a method called JVM creates stack frames.</p><pre>Stack Memory<br><br>|       |<br>| fun3()|<br>|-------|<br>| fun2()|<br>|-------|<br>| fun1()|<br>|-------|</pre><ul><li>Memory is automatically released after method execution.</li><li>Each thread has its own stack memory.</li></ul><h4>ii. Program counter (pc registers)</h4><ul><li>Stores the address of the currently executing instruction.</li><li>Each thread has its own pc register.</li><li>It is thread private which is created once per thread.</li></ul><h4>iii. Native Method stack (JNI methods)</h4><ul><li>Stores the information for native methods written in languages like (c/c++).</li><li>These native methods are called through JNI (Java Native Interface).</li><li>Used when java interacts with native libraries</li><li>JNI acts as a bridge between JVM and native libraries</li></ul><pre>         JNI(Java Native Interface)<br>JVM-------------------------------------------&gt;Native Libraries</pre><pre>package com.memorySpace;<br><br>//class MemoryArchitecture (class metaData) - is stored in MethodArea;<br>public class MemoryArchitecture {<br><br>    //static variables are stored in MethodArea<br>    //static variables only accessible static methods<br>    static String name=&quot;Vignesh T&quot;;<br>    static int age=20;<br><br><br>    //(non-static,object,instance,dynamic) variables are stored in Heap Memory;<br>    String studentName;<br>    int studentId;<br><br>    // Constructor metadata and bytecode are stored in the Method Area.<br>    public MemoryArchitecture(String studentName, int studentId) {<br>        this.studentName = studentName;<br>        this.studentId = studentId;<br>    }<br><br>    //Instance method bytecode is stored in MethodArea<br>    //non-static can access non-static variables<br>    void display() {<br>        System.out.println(&quot;Student : &quot; + studentName);<br>        System.out.println(&quot;Id     : &quot; + studentId);<br>    }<br><br>    //Static method  bytecode is stored in MethodArea<br>    //Static can access static variables<br>    static void showDetails(){<br>        System.out.println(&quot;Name :&quot;+name);<br>        System.out.println(&quot;age :&quot;+age);<br>    }<br><br>    public static void main(String args[]){<br>        MemoryArchitecture m1=new MemoryArchitecture(&quot;Vignesh T&quot;,1);<br>        // Object(new MemoryArchitecture(&quot;Vignesh T&quot;,1)) is stored in Heap Memory.<br>        // Reference variable m1 is stored in stack memory<br><br><br>        //primitive local variable is stored in Stack Memory.<br>        int marks=100;<br>        System.out.println(&quot;Marks :&quot;+marks);<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=318b974f2289" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Software Development Life Cycle (SDLC) Step by Step]]></title>
            <link>https://medium.com/@vignesh4485849/understanding-the-software-development-life-cycle-sdlc-step-by-step-c8a5e0e86907?source=rss-e62ad491b97e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8a5e0e86907</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[sdlc]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 17:06:57 GMT</pubDate>
            <atom:updated>2026-08-05T17:06:57.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTXNRLjZ_KB90sa5ywyCdg.png" /></figure><p>Software Development Life Cycle is a structured process used to plan, design, develop, test and maintain software. It improves, teams to build a high quality of software on time, within budget and without many errors in software building.</p><p>There are seven important phases in SDLC<br>(P-R-S-D-T-D-M — Please Remember: Smart Developers Test, Deploy, Maintain)</p><ol><li>Planning</li><li>Requirement Analysis</li><li>System Design</li><li>Development</li><li>Testing</li><li>Deployment</li><li>Maintenance</li></ol><h3>1. Planning</h3><p>In this phase determining whether the project is possible to build and whether it is worth for build. Through estimating time, budget and understanding root causes.</p><h3>2. Requirement Analysis</h3><p>In this phase clearly understanding what customer wants, and in detail documenting functional and non functional requirements.</p><p>Functional means, what the system should do?<br>For instance: User login, registration, upload docs, report generation etc…</p><p>Non functional means, It mainly focus on fast response, security, reliability, scalability and etc..</p><h3>3. System Design</h3><p>Converting collected requirements into a technical design, In this phase we are planning the software architecture.</p><p>There are two types of design</p><p><em>i. High level design</em><br>It mainly focus the overall architecture like frontend, backend and database</p><p><em>ii. Low level design</em><br>In low level design we are detailing the high level system architecture, for instance login module it has validateUser(), encryptPassword(), generateToken() etc..</p><h3>4. Development</h3><p>In this phase developers actually start writing the code like front creation, developing backend, connecting database and writing other functionalities using programming languages.</p><p>Here they are building working software before testing.</p><h3>5. Testing</h3><p>In testing we need to find and fix the errors before users use the software. It has lots of different testing.</p><h4>Other types of testing:</h4><ol><li>Unit Testing — testing the functions ( calculator.add() ).</li><li>Integration Testing — testing the modules together(login-&gt;dashboard-&gt;database).</li><li>System Testing — testing the whole application</li><li>Acceptance Testing — this test is performed by the client to verify it meets the business needs.</li><li>Performance Testing — testing the speed, performance, loading speed and etc.</li><li>Security Testing — checking authentication, data protection and SQL injection.</li></ol><h3>6. Deployment</h3><p>Releasing our software in browser or to the users, once it is completely tested.</p><h3>7. Maintenance</h3><p>Once it is deployed, we need to check always, it may possible to any error or bug happen in the future. At the same time we need regularly update software every time cause then only it meets the users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8a5e0e86907" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>