<?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 Ankita Chaturvedi on Medium]]></title>
        <description><![CDATA[Stories by Ankita Chaturvedi on Medium]]></description>
        <link>https://medium.com/@ankitachaturvedi0310?source=rss-1b87b1db144c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nRDYgiQN4zI6H2nXPit4fA.jpeg</url>
            <title>Stories by Ankita Chaturvedi on Medium</title>
            <link>https://medium.com/@ankitachaturvedi0310?source=rss-1b87b1db144c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:55:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankitachaturvedi0310/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[Hashmap Concepts : Collision-Chaining, Update/Overwrite, Internal Working]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ankitachaturvedi0310/hashmap-fd8a5ba407ae?source=rss-1b87b1db144c------2"><img src="https://cdn-images-1.medium.com/max/1342/1*JRgeOTczQvRB5xmX8ESptw.png" width="1342"></a></p><p class="medium-feed-snippet">Theoretical definition of Hashmap is implements Map interface and extends AbstractMap. I will explain you all the necessary concepts of&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@ankitachaturvedi0310/hashmap-fd8a5ba407ae?source=rss-1b87b1db144c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ankitachaturvedi0310/hashmap-fd8a5ba407ae?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd8a5ba407ae</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 08:47:56 GMT</pubDate>
            <atom:updated>2026-04-21T08:52:12.089Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Tree Traversals Distilled: Simplest Path to Comprehensive Understanding]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/tree-traversal-24e4fa17a8d2?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/24e4fa17a8d2</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 12:31:11 GMT</pubDate>
            <atom:updated>2026-01-31T15:34:52.061Z</atom:updated>
            <content:encoded><![CDATA[<p>After consulting multiple sources, this blog distills the content into the simplest yet most comprehensive form.</p><p><strong>Prerequisite:</strong> Familiarity with the basics of Tree data structures.</p><p>The process of visiting all nodes is called tree traversal. The sequence in which nodes are processed defines a particular traversal method. Ideally there are six possibilities :</p><ol><li>LDR</li><li>RDL</li><li>DLR</li><li>DRL</li><li>LRD</li><li>RLD</li></ol><p>The classification is based on the order in which current node is processed. Hence if our classification is based on the current node -&gt; D and D is processed in the middle then it does not matter whether L comes on the left of the D or R comes on the left of the D.<br>Thus we discard remaining 03 and keep L and R in the order left first then right.</p><p><strong>Classification of Tree Traversal</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfcGldEHtSaoEQVvp3-Cag.jpeg" /></figure><p><strong>The classification of Depth-First Search (DFS) variants hinges on the processing order of the current (root) node.</strong></p><blockquote><em>1. </em><strong><em>Pre-order Traversal</em></strong><em>(“Pre” denoting “before”): The root node is processed first, followed by left and then right subtrees (Root → Left → Right).​</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rfu8ULvgF6rr51IvjnlYJw.png" /><figcaption>PreOrder Traversal</figcaption></figure><p><strong><em>PreOrder o/p = [1,2,4,5,3,6,7]</em></strong></p><blockquote><em>2. </em><strong><em>In-order Traversal</em></strong><em> (“In” denoting “in-between”): The root node is processed between the left and right subtrees (Left → Root → Right).​</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCM6CL3RfXLsorS8DTqtmQ.png" /><figcaption>InOrder Traversal</figcaption></figure><p><strong>InOrder o/p = [4,2,5,1,6,3,7]</strong></p><blockquote><em>3. </em><strong><em>Post-order Traversal</em></strong><em> (“Post” denoting “after”): The root node is processed last, following both subtrees (Left → Right → Root).</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTgqKCj78V91rSZX8Bu2nA.png" /><figcaption>PostOrder Traversal</figcaption></figure><p><strong>PostOrder Traversal o/p = [4,5,2,6,7,3,1]</strong></p><blockquote><strong>Level Order Traversal </strong>— Visiting nodes level-wise</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MePJ8yAEXIwThBlWnZ40Lw.png" /><figcaption>Level order Traversal</figcaption></figure><p>Level Order o/p = [1,2,3,4,5,6,7]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24e4fa17a8d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arrays in Java]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/arrays-in-java-8ebb00b21eb?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ebb00b21eb</guid>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[arrays-in-java]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Thu, 28 Apr 2022 04:07:00 GMT</pubDate>
            <atom:updated>2022-04-28T04:07:00.530Z</atom:updated>
            <content:encoded><![CDATA[<p>I must start with saying “Arrays is the first ladder of Data Structure” and you will certainly agree with me.</p><p>Every software developer starts their DS journey with “Arrays” so let us also commence with the same.</p><p>I will start with “What is Data Structure”.. think!🧐🧐🤓</p><p>Data Structure is definitely not a storage area. It offers us different ways of storing the data in memory, data gets stored in memory of computer regardless of any DS you use.</p><blockquote><em>1. What is Array? 👀</em></blockquote><blockquote><em>2. How is it different from other Data Structures? 💁</em></blockquote><blockquote><em>3. memory management in Arrays?</em></blockquote><p>Let’s begin with the first question 🤓🤓😎😉…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*nLZe648a1xzVNkYB.gif" /></figure><p>Arrays is indeed a data structure which allows us to store data contiguously and have fixed size which means it goes for static memory allocation because size is allocated during compile time. If you do not understand the concept of static and dynamic memory allocation, please visit — <a href="https://medium.com/@ankitachaturvedi0310/static-and-dynamic-memory-allocation-1f43a0d45f83">https://medium.com/@ankitachaturvedi0310/static-and-dynamic-memory-allocation-1f43a0d45f83</a> to gauge in depth understanding.</p><p>Let’s take a tiny example to visualize it -</p><p>int[] arr; //if I declare an array variable like this, this “arr” variable will be stored in stack memory.</p><p>arr=new int[5]; //this will block a memory of 5*4 bytes (each block which is 20 bytes in heap memory.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ebb00b21eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Static and Dynamic Memory Allocation]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/static-and-dynamic-memory-allocation-1f43a0d45f83?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f43a0d45f83</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 14:05:19 GMT</pubDate>
            <atom:updated>2020-06-02T14:17:57.032Z</atom:updated>
            <content:encoded><![CDATA[<p>What is static memory allocation?? What is Dynamic memory allocation?? What is compile time?? What is run time??</p><p>These questions indeed hit our head if we are new to programming or not aware of memory allocation concept. <strong>This article is a savior Yay!!</strong></p><blockquote><strong>Memory allocated during the compile time is called static memory allocation. The memory allocated is fixed or cannot be changed during run-time.</strong></blockquote><p>What is compile time? — it’s the prior stage wherein code is converted to execution form. In java, .java files are converted to .class files in this stage.</p><p>What is runtime?- It’s the secondary stage wherein .class file is getting executed.</p><blockquote><em>Ex — public void getValue{</em></blockquote><blockquote><em>int[] array = {1,2,3,4,5}; // this is static memory allocation.</em></blockquote><blockquote><em>}</em></blockquote><h4>Drawbacks of static memory allocation</h4><ul><li>Size is fixed and cannot be increased or decreased during runtime. If we have assigned huge size and does not use it full fledged then we will end up wasting the memory or in vice versa case we will run out of memory which is called <strong>Stack Overflow</strong>. Thus Dynamic Memory allocation concept came into picture to rescue.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*T7pQALUpXUV7P8FODwc2Rw.png" /><figcaption>MEMORY ASSIGNED TO PROGRAM</figcaption></figure><p>Operating System assigns memory to particular application or program and above is the architecture of memory.</p><p>As shown in above diagram, memory is divided into 04 segments — Heap, Stack , static/global are stored in data segment and code or instructions.</p><h3>STACK</h3><p>Functions and local variables are stored in stack. Small segment of stack memory is assigned to main method which is also called stack-frame as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*RyxVUHtalDbLwWEF1b0fFQ.png" /><figcaption>Stack Architecture</figcaption></figure><blockquote><em>Lets taken an example to understand this thoroughly -</em></blockquote><blockquote><em>public class DynamicMemory {<br> <br> public int getSum(int a, int b) { // function with local variables a,b and z<br> int z= a+b;<br> return z;<br> }</em></blockquote><blockquote><em>public static void main(String[] args) {</em></blockquote><blockquote><em>DynamicMemory obj = new DynamicMemory();<br> int x=10;<br> int y=20;<br> int sum=obj.getSum(x, y);<br> System.out.println(“sum of 02 nos.= “ +sum);<br> }</em></blockquote><blockquote><em>}</em></blockquote><p><strong>Steps of execution of this program -</strong></p><ol><li><em>Main method along with local variables x,y and z will be stored in stack in stack-frame memory area.</em></li><li><em>getSum() function and its local variables a and b will be stored in Stack.</em></li><li><em>Now main function is paused until getSum() function is executed and returns value.</em></li><li><em>Once getSum() function is executed and returns value, it will be erased from stack and main method will be into play mode and once it is also executed, it will be erased from stack. Now stack is empty.</em></li><li><em>This concept is essential for Recurssion.</em></li></ol><p><em>Stack stores the data until function is executed.</em></p><h3><strong>Heap</strong></h3><blockquote>The process of allocating memory during the run time or at the time of execution is called Dynamic Memory Allocation.</blockquote><blockquote>Heap is the segment of memory where dynamic memory allocation takes place. Unlike stack where memory is allocated and de-allocated in defined order as seen above, heap is the memory segment where allocation and de-allocation happens randomly.</blockquote><blockquote>Objects and Instance variables are stored in Heap area.</blockquote><blockquote><strong>DynamicMemory obj = new DynamicMemory(); // it will be stored in heap memory.</strong></blockquote><p>Thank you:-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f43a0d45f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Instanceof in java]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/instanceof-in-java-870456f5dc60?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/870456f5dc60</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 14:46:26 GMT</pubDate>
            <atom:updated>2020-06-01T16:15:15.016Z</atom:updated>
            <content:encoded><![CDATA[<h3>Instanceof keyword in java</h3><h4>Instanceof keyword checks if the reference variable contains given type of object or object is an instance of given type.</h4><p>It’s a comparison operator and returns true or false.</p><p>Lets see all possible scenarios to understand how this keyword can be used -</p><blockquote>class Parent {</blockquote><blockquote>}</blockquote><blockquote>class Child extends Parent{</blockquote><blockquote>}</blockquote><p>In above code, child is extending parent class or say inheriting the properties of parent class. Below are the possible scenarios -</p><ol><li>Parent parent = new Parent(); //created parent object using parent class reference.</li></ol><p>2. Child child = new Child(); //created Child class object using child class reference.</p><p>3. Parent parent1=new Child(); //created child object using parent class reference.</p><p>4. Child child = new Parent(); // No, this is not possible.</p><ul><li>As we all know Object is the superclass or root of class hierarchy. hence child and parent reference both can be the instance of Object class;</li></ul><blockquote><em>(parent instanceof Parent()) // true</em></blockquote><blockquote><em>(child instanceof Child()) // true</em></blockquote><blockquote><em>(child instanceof Parent()) // true</em></blockquote><blockquote><em>(child instanceof Object()) //true</em></blockquote><blockquote><em>(parent instanceof Child()) // false</em></blockquote><blockquote><em>(parent1 instanceof Child()) // true</em></blockquote><p>It’s quite clear from above statements that child can be instance of its parent and super class but vice versa is not true.</p><p>It takes reference variable and object and checks if the reference contains the object or not.</p><blockquote>However, we need to focus on scenario wherein we have created the object of Child class using Parent class reference.</blockquote><blockquote>Parent parent1=new Child();</blockquote><blockquote><strong>(parent1 instanceof Child()) //true;</strong></blockquote><blockquote>when you create an object of child class using parent class reference, in such case, parent reference can be instanceof Child class object.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=870456f5dc60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strings in Java]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/strings-in-java-f44f9e316789?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f44f9e316789</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Fri, 29 May 2020 12:56:31 GMT</pubDate>
            <atom:updated>2020-05-29T18:03:09.645Z</atom:updated>
            <content:encoded><![CDATA[<h4>String Class and String Methods and Memory Optimization concept in string.</h4><blockquote><em>String is a very prominent and significant topic in java. So let’s have a look and understand the concept of String in depth.</em></blockquote><h3><strong>What is String?</strong></h3><blockquote><strong><em>Strings are objects in java and String is an array of characters internally.</em></strong></blockquote><blockquote>array of characters- char[] arr= {‘a’, ’b’, ’c’};</blockquote><blockquote>object- String abc=new String(“Welcome”);</blockquote><p>String class belongs to java.lang.String package which implements Comparable interface, Serializable and CharSequence. If you click on String and check its implementation you will see this -</p><p><strong>public final class String<br> implements java.io.Serializable, Comparable&lt;String&gt;, CharSequence {</strong></p><p><strong>}</strong></p><p>String class has peer classes StringBuilder and StringBuffer. String class is an immutable class whereas StringBuffer and StringBuilder are mutable.</p><p><strong><em>How StringBuilder and StringBuffer are different from each other -</em></strong></p><p><strong><em>StringBuilder </em></strong><em>is not thread safe i.e not synchronized and </em><strong>StringBuffer</strong> <em>is synchronized i.e. thread safe..</em></p><h3>Ways to create String in java</h3><ol><li><strong>using literals (literal is nothing but double quotes “”)</strong></li><li><strong>using new keyword</strong></li></ol><p>why do we have two ways of creating string object not one. This is because of memory optimization concept in String. Let deep dive into this topic and get more clarity on it -</p><p>String s1=”java”;</p><p>When we create a string using literal, it is stored in String Constant Pool. Now the question arises what is <strong>String Constant Pool?</strong></p><p>String constant pool is a memory area inside Heap memory. Also, as the name implies String <strong>Constant </strong>stores constant data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*mcpyxVkGrzWoT2Vt.png" /><figcaption><strong>String Constant Pool inside Heap Memory</strong></figcaption></figure><p><strong>Why String Constant Pool is introduced?</strong></p><p>As strings are immutable in nature therefore String Constant Pool came into the picture. It also saves the space for java runtime.</p><p>As mentioned before when we create string using literal, string object is stored in String Constant Pool.</p><p>String s1=”java”;</p><p>String s2=”java”; Now I have created 02 objects with different reference variables s1, s2 and with same content “java’ using literals. what happens next?</p><p>Only one object will be created in String constant pool “java” and both reference variables s1 and s1 point to same object as shown in above picture. Here s1==s2 as both references are pointing to the same object.</p><p><strong>This means String constant pool does not allow duplicate objects. Literals are created only once and aids in saving memory by creating object only once.</strong></p><h4>What if I want create a new object with same content?</h4><p>We will create new object with same content using new keyword and it will store the object in heap memory.</p><p>String s3=new String(“java”);</p><p>String s4= new String(“java”);</p><p>This will create 02 different objects in heap memory with same content. Here s3==s4 is false as both reference variables are pointing to 02 different objects and == compares the reference of objects in java.</p><h3>String Methods</h3><p>There are some common string methods which are often used in java.</p><p><strong>.equals()</strong> — compares the content of String objects.</p><p><strong>.equalsIgnoreCase()</strong> -It is same as equals method but not case sensitive.</p><p><strong>.length()</strong>-returns length of the string.</p><p><strong>.charAt(index)</strong>-returns character at given index.</p><p><strong>.toUpperCase()</strong>-returns the string in uppercase.</p><p><strong>.toLowerCase()</strong>-returns the string in lowercase.</p><p><strong>.trim()</strong>-removes all white spaces in string.</p><p><strong>.contains()</strong>-search for given word or character in string.</p><p><strong>.toCharArray()</strong>-return the array of characters.</p><p><strong>.IsEmpty()</strong>-returns boolean.</p><p><strong>.split(regex)</strong>-split the string on the basis of regex.</p><p><strong>.compareTo()</strong>-compares with another string.</p><p><strong>.concat()</strong>-append string to existing string.</p><p><strong>.hashcode()</strong>-returns hashcode of string which is a int datatype.</p><p><strong>.endsWith(suffix)</strong>-returns boolean if the string ends with given suffix. Mostly used to check the extension of image like .png, .JPEG.</p><p><strong>.startsWith(prefix)</strong>-same as previous one and returns boolean.</p><h4>StringTokenizer class</h4><p>StringTokenizer class in java breaks a string into tokens and comes with various methods. Methods of stringtokenizer are highlighted in bold.</p><p>String str=”How are you?”;</p><p>StringTokenizer token= new StringTokenizer(str);<br>token.<strong>countTokens()</strong>;//output=3<br> token.<strong>nextElement()</strong>;//How<br> token.<strong>nextElement()</strong>;//are<br> token.<strong>nextElement()</strong>;//you?<br> token.<strong>hasMoreElements()</strong>;//false</p><p>token.<strong>hasMoreTokens()</strong>;//false</p><p>THANK YOU! -:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f44f9e316789" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Autoboxing and Unboxing]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/autoboxing-and-unboxing-6189fe58ea90?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6189fe58ea90</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Thu, 28 May 2020 15:17:16 GMT</pubDate>
            <atom:updated>2020-05-28T15:45:37.880Z</atom:updated>
            <content:encoded><![CDATA[<p>Before you start with these two concepts, recommend you to walk through wrapper class concept and below is the link for the same-</p><p><a href="https://medium.com/@ankitachaturvedi0310/wrapper-class-and-why-do-we-need-wrappe-8662cdf76e62?source=friends_link&amp;sk=54ed0f55aa2a47359371b8d8176e6bc4">https://medium.com/@ankitachaturvedi0310/wrapper-class-and-why-do-we-need-wrappe-8662cdf76e62?source=friends_link&amp;sk=54ed0f55aa2a47359371b8d8176e6bc4</a></p><p>Auto-boxing and Unboxing concepts are related to wrapper class and primitive values.</p><p>Auto-boxing -converting primitive values to objects or in other words you can say wrapping the primitive values into wrapper class objects.</p><p>Unboxing — name itself implies that it is a process of unwrapping the objects to primitive values.</p><p>Both auto-boxing and unboxing are performed by java compiler.</p><p>Lets take an example below -</p><p>public class AutoBoxingAndUnboxing {</p><p>public static void main(String[] args) {<br> int variable=10;<br> Integer object= new Integer(variable);</p><p>//converting int to Integer (primitive value to its corresponding object)<br> System.out.println(“Auto-Boxing = “ +object);<br> int unboxing=object;</p><p>//converting Integer to int (wrapper object to its corresponding primitive //value) and Auto-boxing to unboxing<br> System.out.println(“Unboxing = “ +unboxing);<br> }</p><p>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6189fe58ea90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wrapper Class and Why do we need wrappe]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/wrapper-class-and-why-do-we-need-wrappe-8662cdf76e62?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8662cdf76e62</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Wed, 27 May 2020 11:17:01 GMT</pubDate>
            <atom:updated>2020-05-28T14:41:37.717Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wrapper Class and Why do we need wrapper class</h3><p>Wrapper class is a predefined class in java and wrapper class objects wrap primitive data type. In simple words, wrapper class converts the datatype to objects.</p><p>Primitive datatype are variables therefore it does not belong to any class and cannot be instantiated.This is the reason wrapper class came into picture.</p><p>Each primitive datatype is mapped with dedicated wrapper class and below is the list of same -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/0*APElZELuk5wtT854.png" /><figcaption>Primitive data type mapped with dedicated Wrapper class.</figcaption></figure><p>If you see above image carefully, you will scrutinize primitive data type starts with lower case and wrapper class name begins with upper case. Variable name always begins with lower case and class name begins with upper case.</p><p>All wrapper class name are exactly same as data type except char-Character and int-Integer.</p><p>Wrapper classes belong to java.lang package.</p><p><strong>Why do we need wrapper class?</strong></p><p>If you have worked with collections like Arraylist, Vectors , HashMap they have generic&lt;&gt; which accepts object not primitive data type. Lets take an example -</p><p>ArrayList&lt;Integer&gt; list= new ArrayList&lt;Integer&gt;();</p><p>&lt;&gt; will not accept primitive data type, it accepts object. It converts the primitive data-type into objects.</p><p>Wrapper class are immutable as object reference are passed by value. If you have gone through my previous article- Pass by Value and Pass By Reference link-<a href="https://medium.com/@ankitachaturvedi0310/call-by-value-and-call-by-reference-76071376841d">https://medium.com/@ankitachaturvedi0310/call-by-value-and-call-by-reference-76071376841d</a>, you can easily comprehend the concept here.</p><p>If you apply any operation on wrapper class object, it wont change the value instead it will create a new object. See below example and run on your machine -</p><p><em>public class WrapperClass {</em></p><p><em>public static int processedValue(Integer value) {<br> value = value + 10;<br> return value;<br> }</em></p><p><em>public static void main(String[] args) {<br> int i = 10;<br> Integer value = new Integer(i);<br> System.out.println(“Wrapper class object= “ + value);</em></p><p><em>//create a new object and store modified value, it will work<br> processedValue(value);<br> System.out.println(“Modified Value= “ + value);</em></p><p><em>}</em></p><p><em>}</em></p><p>O/P=Wrapper class object= 10<br>Modified Value= 10</p><p>Here I tried to modify the original value of the object reference but I could not do that. But if you create a new object here and store the modified value in that object, it will certainly work.</p><p><strong>NOTE* -<em>Wrapper class hold more space than primitive data type.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8662cdf76e62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Cloud Netflix — Eureka]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/spring-cloud-netflix-eureka-31960b82bf37?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/31960b82bf37</guid>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Sun, 24 May 2020 19:50:15 GMT</pubDate>
            <atom:updated>2020-05-27T08:48:54.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>Spring Cloud Netflix — Eureka</h3><p>Microservices are nothing but small spring boot applications which are intent to perform specific task.</p><p>When developing distributed microservices with spring boot, we face numerous issues hence to mitigate those issues, we use Spring Cloud Netflix.</p><p><em>Spring Cloud Netflix consists of patterns like Eureka(Service Registry and Service Discovery), Hystrix (Circuit Breaker), Zuul (Intelligent Router) and Ribbon(Load Balancer).</em></p><p>In this article, I will primarily focus on Eureka which is also called Service Registry and Service Discovery.</p><p>Lets take an example and deep dive into this topic -</p><p>We have two modules here Employee-Producer and Employee-Consumer. Ideally we establish the communication directly between both of them as shown below-</p><h4>EMPLOYEE-PRODUCER — — — — — — —EMPLOYEE-CONSUMER</h4><ul><li>Here Employee Producer has exposed a Rest API which will be consumed by the Employee Consumer.</li></ul><p><strong>In this case, we will store the configuration and server info in properties file which is a static data and if the server goes down at the particular port then Employee Consumer will fail to establish the communication with Employee Producer on that particular port.</strong></p><p>Therefore to evade such scenarios, we will use Netflix Eureka as a bridge between Employee Producer and Employee Consumer as shown below-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*pqv7lJxPvUkR9OGK3YvkNA.png" /><figcaption>Eureka Service Registry and Service Discovery</figcaption></figure><p>This image clearly states that for Producer module it acts as Service Registry and for Consumer module, it acts as Service Discovery.</p><h4>Notes -</h4><blockquote>Eureka Server is a directory which maintains the information of active servers of both modules producer as well as consumer.</blockquote><blockquote>You may name the applications as shown above thus it becomes easy for you to figure out, which app is running on which port.</blockquote><blockquote>An application can have multiple instances running on different ports therefore generate random or unique id with the name of application. This will help you to understand which instance is running on which port.</blockquote><blockquote>Eureka Server offers a dashboard just like H2 database wherein you can view all the details of application like no of instances of an app with their unique ids and port numbers.</blockquote><blockquote>Producer module will register itself in Eureka Server, you can view the instance of this app on Eureka Server dashboard. Producer module registers itself on Eureka Server that is why it is called Eureka Registry.</blockquote><blockquote>Consumer module communicates with Eureka Server and discovers the instance of the producer and consume the API and that is why it is called Eureka Discovery.</blockquote><p>I will explain the implementation part in next article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31960b82bf37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Call by Value and Call by Reference]]></title>
            <link>https://medium.com/@ankitachaturvedi0310/call-by-value-and-call-by-reference-76071376841d?source=rss-1b87b1db144c------2</link>
            <guid isPermaLink="false">https://medium.com/p/76071376841d</guid>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[pointers]]></category>
            <category><![CDATA[reference]]></category>
            <dc:creator><![CDATA[Ankita Chaturvedi]]></dc:creator>
            <pubDate>Sat, 23 May 2020 20:40:08 GMT</pubDate>
            <atom:updated>2020-05-24T18:12:38.125Z</atom:updated>
            <content:encoded><![CDATA[<h4>Call by value and call by reference often puzzle developers hence explaining it in most simple words.</h4><h4>Call By Value</h4><blockquote><strong><em>Actual Parameters</em></strong> — Parameters passed to a function.</blockquote><p><strong>Temporary/Formal Parameters </strong>— Parameters received by a function.</p><p>Lets see an example below-</p><p>Parameters passed to a function — subtract(a, b) and say a=5 and b=10;</p><p>when we pass a and b to method subtract then the values of a and b will be copied to formal parameters x and y. So, now x=5 and y=10.</p><blockquote>Remember, formal parameters and actual parameters are stored in different memory locations.</blockquote><p>Parameter received by a function —</p><p>public int subtract(int x, int y){</p><p>return (x-y);</p><p>}</p><p>NOTE*:: If you manipulate or apply any operation on these values inside the function that will not reflect in a and b. Once the function is executed and you print a and b, you will get the original value.</p><p>In Call by Value, we are simply passing the values itself and not the variables.</p><p><strong>Call By Reference</strong></p><blockquote><em>Actual Parameters and Formal Parameters refers to the same memory location </em>and any changes made to the formal parameters will reflect in original/actual parameters.</blockquote><p>In Call by Reference, we pass addresses instead of values.</p><p>Lets see a small example below in order to get more clarity-</p><p>int x=10; int y=50;</p><p>func(&amp;x, &amp;y); &amp; means address of x and y</p><p>int func(int *ptr, int *ptr1){</p><p>*ptr=100;</p><p>*prt1=200;</p><p>}</p><p>x=10 at 100 memory address and y=50 at 1000 memory address.</p><p>ptr=100 and ptr1=1000 -These pointers will point to memory address and access the value at memory address100 and 1000 and make changes to actual values.</p><p>In short the addresses are mapped to the actual values. We can directly access the actual values via pointers and manipulate the actual values present at that address.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76071376841d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>