<?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[JavaMadeTranquil - Medium]]></title>
        <description><![CDATA[Find all concepts of Java | OOPs | Data Structures and Algorithms | Multi threading | Design Patterns — The Ultimate Core Java Guide! Collaboration of the best possible example techniques used to explain any Concept. - Medium]]></description>
        <link>https://medium.com/javamadetranquil?source=rss----6f7e51fba52---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>JavaMadeTranquil - Medium</title>
            <link>https://medium.com/javamadetranquil?source=rss----6f7e51fba52---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:17:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/javamadetranquil" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Memory allocation in Java:]]></title>
            <link>https://medium.com/javamadetranquil/memory-allocation-in-java-fb2d4498a3ed?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/fb2d4498a3ed</guid>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[memory-management]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Sun, 22 Feb 2026 20:56:26 GMT</pubDate>
            <atom:updated>2026-02-22T20:56:28.333Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mc_q3hwWRMxnkl_a5ixL1g.jpeg" /><figcaption><strong>Memory allocation!</strong></figcaption></figure><p>Hello Comrades,</p><p>Keeping it simple to understand I will be covering here just a basic walkthrough on what a memory allocation in Java is all about? As we all are aware that a JVM is an abstract computing machine which enables a computer to run a program. The JVM loads the code, verifies it, executes it, manages the memory[allocating memory from OS, managing Java allocation including heap compaction and garbage collection] and provides the runtime environment.</p><p>Memory allocation being a part of JVM [Java Virtual Machine]. So understanding why Java needs a JVM and no other languages needs a VM is important at this point. In many other languages, the compiler produces the machine code for a specific system, however, in Java, the Java compiler always produces a code for the virtual machine which is called JVM and not for the specific system. It is JVM which holds tag of being platform dependent, thus making Java - a platform independent programming language. A JVM converts the Java bytecode to the machine interpretable language. The two primary functions of JVM is to allow Java program to run on any device or operating system and to manage and optimize the program memory.</p><p>Memory management is a form of resource management applied to a computer memory. The essential requirement of memory management is to provide ways to allocate portions of memory to programs at their request, and free it for reuse when no longer needed.</p><p>To have an even better understanding of the article, I would suggest you to read <a href="https://medium.com/javamadetranquil/jvm-architecture-29f6ab33e208">this</a> article prior to proceeding ahead.</p><p>As mentioned above we will proceed ahead understanding concepts on how a memory allocation is done and what errors can occur in case of memory shortage. Memory allocation is an action of assigning the physical or the virtual memory address space to a process.</p><p>JVM memory is divided into multiple parts : Heap |Non-Heap |others. Heap memory is the runtime data area from which the memory for all the java class instances and arrays is allocated. The heap is created when JVM starts-up and may increase or decrease in size as application runs. Non-Heap memory is created at the time of JVM start-up and stores per-class structures such as fields and methods data as well as interned strings [String Interning is a method of storing only one copy of each distinct String Value, which must be immutable. By applying String.intern() on a couple of strings will ensure that all strings having the same contents share the same memory]. The other memory is used to store JVM code itself, JVM internal structures, loaded profile agent codes and data. The two fundamental methods of memory allocation are static and dynamic memory allocation.</p><blockquote><strong>Static memory allocation</strong> assigns the <strong>memory</strong> <strong>before its execution</strong> where as <strong>dynamic memory allocation </strong>assigns the <strong>memory to a process during the execution.</strong></blockquote><p>Memory allocation is general aspect of term “binding”. Assume we declare a variable of a class type and create a reference to it. For storing any values to these variables, we must have memory allocated to them. Hence we can term memory allocation as “an act of assigning the memory address to the attributes of the variables”</p><pre>eg: int a = 10;</pre><p>Static memory allocation is when a compiler compiles the program and generates object files, the linker merges these object files to an executable file and with the help of a loader this executable file is loaded in the main memory. The size of the data required by the process has to be known prior to execution in static allocation, thus making it more efficient leading to a faster execution of a process. Dynamic memory allocation takes place during the execution of a program. Here the memory is allocated to the entities when they are used for the first time while the program executes. It reduces memory wastage as it allocates the exact memory space needed by the entity.</p><p>Memory management is the functionality of an operating system which handles primary memory and move the processes back and forth the main memory and disk during execution. Some basic concepts dealing with memory management could be Process Address space, Static|Dynamic loading and linking.</p><ul><li><strong>Process Address space:</strong> It is a set of logical address that a process references in its code. The OS takes care of mapping the logical address to the physical address at the time of memory allocation to the program. There are three types of address being used before and after memory allocation is done. <strong>Symbolic address, Relative address and Physical address…</strong> Symbolic addresses are the addresses that are used in a source code by variable names, constants and instruction labels. Relative addresses are the addresses that are converted from symbolic address at the compile time. And when the program is loaded into the main memory, the loader generated Physical Addresses. The Virtual and Physical address remains same in case of compile time but differs while execution [runtime].</li><li><strong>Static Vs Dynamic Loading and Linking:</strong> The decision of choosing static or dynamic loading is to be taken at the time of program being developed. If we have to load the program statically, then at the time of compilation, the complete program will be compiled and linked without leaving any external module dependencies. The linker combines the object program with other necessary object modules along with logical addresses.Whereas if we are loading a dynamic program, the compiler will then compile the program and the references of module dependencies that shall be needed. by the program will be provided. When static linking is used, the linker combines all other modules needed by the program into a single executable program to avoid any runtime dependencies. Whereas in case of dynamic linking it is not needed to link the actual module or library with the program, rather references to thm can be attached.</li></ul><p>Memory isn’t allocated at the time of object declaration, it gets allocated at the time of reference. For the memory allocation of objects , new() method is used, hence objects are always allocated in the heap memory.<strong> The Java Memory Allocation is divided into Heap, Stack, Code and Static section for an effective management. </strong>The Code section contains the bytecode, stack contains methods, local variables and reference variables, Heap section containing Objects and might also contain reference variables and the Static section contains only the static data|methods.</p><p>A most common error caused in Memory Allocation is <strong>“java.lang.OutOfMemoryError ”</strong>, usually this is thrown when the JVM cannot allocate an object because it is out of memory and no more memory could be available by the garbage collector. [We ll read about exceptions and errors in upcoming article]</p><p>Hope this article helps you in a little better understanding of the memory allocation in Java.</p><p>Until next time…</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb2d4498a3ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/memory-allocation-in-java-fb2d4498a3ed">Memory allocation in Java:</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OOPs Concept In Java:]]></title>
            <link>https://medium.com/javamadetranquil/oops-concept-in-java-1a934f42b7f?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/1a934f42b7f</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[oops-concepts]]></category>
            <category><![CDATA[médium]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Sat, 27 Feb 2021 16:28:23 GMT</pubDate>
            <atom:updated>2021-02-27T16:28:05.339Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*ifCmhafvzD2UpqJvVXfjDA.png" /><figcaption><strong>Object Oriented Programming System!</strong></figcaption></figure><p>Hello Comrades,</p><p>We will be looking into one of the most primary concept of Java — the OOPs concept. Basically, <strong>Java OOP concepts</strong> lets us create working methods and variables, then re-use all or part of them without compromising security.</p><p><strong>Object Oriented Programming is a programming paradigm that relies on the concepts of classes and objects.</strong> Java is a class-based object-oriented programming (OOP) language that is built around the concept of objects. OOP concepts intend to improve code readability and reusability by defining how to structure a Java program efficiently. The main principles of object-oriented programming are: <strong>Abstraction, Encapsulation, Inheritance, Polymorphism, Association, Aggregation and Composition. OOP </strong>is used to structure the software program into a simple, reusable code [usually called classes]. <strong>The building blocks of OOP concepts are Classes, Objects, methods and attributes.</strong> A class is a user defined data type, where we create blueprint for the structures of methods and attributes. Classes contains fields for attributes and methods for behaviours. Objects are instances of classes created with specific data. Attributes are the individuals that differentiate one object from another and determine the appearance, state, or other qualities of that object. Attributes are defined in classes by variables. Method represents behaviour, they perform actions and might return values of an object.</p><blockquote><strong>Understanding the OOP Principles:</strong></blockquote><ul><li><strong>Abstraction:</strong> Abstraction means data hiding…. i.e. <strong>hiding the complexity of implementation and exposing the essential features</strong>. Its main goal is to handle complexity by hiding unnecessary details from the user.</li></ul><p><strong>A real life example to relate to</strong>: Making coffee with a coffee machine is a good example of abstraction. You need to know how to use your coffee machine to make coffee. You need to provide water or milk and coffee beans, switch it on and select the kind of coffee you want to get. The thing you don’t need to know is how the coffee machine is working internally to brew a fresh cup of delicious coffee. You don’t need to know the ideal temperature of the water or the amount of ground coffee you need to use. You just interact with a simple interface that doesn’t require any knowledge about the internal implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NghumbbxLXJM86lhZDlOQQ.png" /><figcaption><strong>abstraction</strong></figcaption></figure><ul><li><strong>Encapsulation:</strong> Encapsulation is the <strong>process of keeping the data and the code that manipulates that data together as a unit</strong>. Since encapsulation is more about protecting data from being accessed by other classes so encapsulation is also referred as data hiding. It describes the idea of bundling data and methods that work on that data within one unit. If you’re familiar with any object-oriented programming language, you probably know that these methods as<strong> getter and setter methods.</strong> As the names indicate, a getter method retrieves an attribute, and a setter method changes it. Depending on the methods that you implement, you can decide if an attribute can be read and changed, or if it’s read-only, or if it is not visible at all. You can use the encapsulation concept to implement an information-hiding mechanism. Similar to the abstraction concept, this is one of the most commonly used mechanisms in Java.</li></ul><p><strong>A real life example to relate to</strong>: The common example of encapsulation is capsule. In capsule all medicine are encapsulated inside capsule. Basically, capsule encapsulates several combinations of medicine. If combinations of medicine are variables and methods then the capsule will act as a class and the whole process is called Encapsulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCnUpjwc5Aae_ObPMaktLQ.png" /><figcaption><strong>encapsulation</strong></figcaption></figure><ul><li><strong>Inheritance: </strong>Inheritance is a mechanism by which <strong>a class inherits the properties and methods of another class</strong>. <strong>SuperClass</strong>– The class whose members are inherited by another class is known as the superclass (also base class or parent class). <strong>SubClass</strong>– The inheriting class is known as the sub class (also as derived or child class). Sub class can also add fields and methods of its own other than what it inherits from the parent class. Sub class can also override the method of the parent class. There are many types of Inheritance single inheritance, multi-level inheritance, hybrid inheritance and hierarchical inheritance. Inheritance is a concept that <strong>enables you to implement a subclass that extends a superclass. </strong>By doing that, the subclass inherits all protected and public attributes and methods, and the types of the superclass. You can then use the inherited attributes of the superclass, <strong>use or override the inherited methods</strong>, and <strong>cast the subclass to any type of its superclass</strong>. You can use an abstract class to define a general abstraction that can’t be instantiated. Within that class, you can declare abstract methods that need to be overridden by non-abstract subclasses. That is often used if the implementation of that method is specific for each subclass, but you want to define a general API for all classes of the hierarchy. <strong>Java doesn’t support multiple inheritance.</strong></li></ul><p><strong>A real life example to relate to</strong>: A child and parent, almost all the properties of father are inherited by his child, also a child can have its own properties as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yu4tT4bfw8un-GP7N4bAtg.jpeg" /><figcaption><strong>inheritance</strong></figcaption></figure><ul><li><strong>Polymorphism: </strong>Polymorphism is a Greek word where poly means “many” and morph means “change from one form to another”. In object oriented terms it relates to the <em>same object reference taking many forms</em>. The concept of polymorphism in Java is designed as an interface having a method and the derived classes implementing the interface as per their requirement. Then using the reference of that single interface any of those implemented class methods can be invoked. So one interface reference can take many forms here based on which class it is referring to. There are two types of Polymorphism in Java- <strong>Compile time polymorphism</strong>– Also known as <strong>static polymorphism</strong>. Static polymorphism in Java is achieved through Method overloading as it is known at compile time itself which of the overloaded method will be called. <strong>Runtime polymorphism</strong>– Also known as <strong>dynamic polymorphism</strong>. Dynamic polymorphism in Java is achieved through Method overriding. In method overriding it is resolved at run time which of the overridden method would be called.</li></ul><p><strong>A real life example to relate to</strong>: A human can have multiple behavioral forms.In a shopping mall we behave like customers, in a class we behave like student, at home we behave like kids, at work we behave like an employee.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*thYk-Mr6Xo57pqWKJp3Ngg.png" /><figcaption><strong>an electronic item can be of any form: Polymorphism</strong></figcaption></figure><ul><li><strong>Association: </strong>Association is relation between <strong>two separate classes which establishes through their Objects</strong>. Association can be one-to-one, one-to-many, many-to-one, many-to-many. <strong>Composition</strong> and <strong>Aggregation</strong> are the two forms of association. <strong>Aggregation </strong>is a special form of Association where: it represents <strong>Has-A</strong> relationship, it is a <strong>unidirectional association</strong> i.e. a one way relationship. For example, department can have students but vice versa is not possible and thus unidirectional in nature. In Aggregation,<strong> both the entries can survive individually</strong> which means ending one entity will not affect the other entity. Composition is a restricted form of Aggregation in which two entities are highly dependent on each other. <strong>Composition </strong>represents <strong>part-of</strong> relationship. In composition, both the entities are dependent on each other. When there is a composition between two entities, the composed object <strong>cannot exist</strong> without the other entity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*xg35rwX24rOGyttOm9OIuQ.png" /><figcaption><strong>Association</strong></figcaption></figure><p>Hope this article brings in clarity of understanding these OOPs concept of Java.</p><p>Until next time…</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a934f42b7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/oops-concept-in-java-1a934f42b7f">OOPs Concept In Java:</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Sorting Algorithm!]]></title>
            <link>https://medium.com/javamadetranquil/the-sorting-algorithm-adf611990c06?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/adf611990c06</guid>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Sat, 16 Jan 2021 09:51:45 GMT</pubDate>
            <atom:updated>2021-01-18T17:42:20.773Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jcGHlQB8h2GH4SWoCw923g.jpeg" /><figcaption><strong>Sorting arranges the data in a sequence which makes searching easier.</strong></figcaption></figure><h3>The Sorting Algorithm!~Part 1</h3><blockquote><strong>Sorting is any process which involves arranging of items(data) systematically holding two common yet distinct meanings to it :</strong></blockquote><blockquote><strong>ordering: </strong>arranging the items in a sequence ordered by some given criterion</blockquote><blockquote><strong>categorizing: </strong>grouping the items which holds similar or alike properties.</blockquote><blockquote>The importance of sorting lies in the fact that the <strong>data searching can be optimized</strong> to an extreme high level.</blockquote><p>Hello Comrades,</p><p>A very common thing that comes to a developers’ mind is why study sorting when languages like C, C++, Python, Java already has built-in sorting algorithms written ….. To bring it to your notice, Lets us understand how are these Sorting algorithms made : <strong>The Python and Java sorting functions are based on Tim-Sort [hybrid of merge sort and insertion sort], where as the C++ Sorting function is based on Intro-Sort [hybrid of quick sort , Insertion sort and heap sort]. C uses sorting function based on Quick-Sort.</strong></p><p>To bring a clarity of how these sorting algorithms are implemented, today we will be understanding the use of sorting and most of the types of sorting algorithm that can help us solve a problem with efficiency. The main advantage of sorting is <strong>“time complexity”</strong>. What is a time complexity? It is the computational complexity that typically <strong>describes the amount of computer time it will take to run an algorithm</strong>.[ we can discuss this in detail in some upcoming posts]. Although there are no.of sorting algorithms, best algorithm is which which can solve a problem in minimum time and space complexity!</p><blockquote><strong><em>I will be releasing a series of articles on these mentioned sorting algorithms:</em></strong></blockquote><p>Some sorting algorithms are as mentioned :</p><ul><li>Bubble Sorting</li><li>Insertion Sorting</li><li>Selection Sorting</li><li>Quick Sorting</li><li>Heap Sorting</li><li>Counting Sorting</li><li>Bucket Sorting</li><li>Radix Sorting</li><li>Shell Sorting</li><li>Comb Sorting</li><li>Cycle Sorting</li><li>Bitonic Sorting</li><li>Tree Sorting</li><li>Stooge Sorting</li></ul><blockquote><strong>*Bubble Sorting</strong></blockquote><blockquote>The bubble sorting, sometimes referred as sinking sorting is a comparison-based and the simplest sorting algorithm that repeatedly steps through a list of data, compares adjacent element and swaps them , if not in correct order.</blockquote><blockquote><strong>Working :</strong> It sorts a given set of “n” elements provided in a form of an array with “n” no.of elements. Now assume if an array is to be sorted in an ascending order, so here the sorting algorithm will start by comparing the first element of the array to the second element, if the first element happens to be greater than the second element, it will swap the elements and further will move ahead to compare the second and third elements and so on, until the elements are sorted.Hence if we have “n” elements, we will be performing the sorting “n-1” times.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*RfHrEI8NAlfbfhduORRcdg.png" /><figcaption>pic credit : w3resources.com</figcaption></figure><p><strong>Code Snippet:</strong></p><pre><strong>class</strong> BubbleSorting{</pre><pre><strong>static</strong> <strong>void</strong> bubbleSort(<strong>int</strong> arr[], <strong>int</strong> n). // <em>parameters as input array and size of the array</em></pre><pre>{</pre><pre><strong>int</strong> i, j, temp;</pre><pre><strong>boolean</strong> swapped; // <em>using for optimization.. so that we don&#39;t swap the already swapped elements in the array</em></pre><pre><strong>for</strong> (i = 0; i &lt; n - 1; i++)// <em>for the iteration of the complete array elements</em></pre><pre>{</pre><pre>swapped = <strong>false</strong>;</pre><pre><strong>for</strong> (j = 0; j &lt; n - i - 1; j++)//for the adjacent element in the array</pre><pre>{</pre><pre><strong>if</strong> (arr[j] &gt; arr[j + 1])</pre><pre>{</pre><pre>temp = arr[j];</pre><pre>arr[j] = arr[j + 1];</pre><pre>arr[j + 1] = temp;</pre><pre>swapped = <strong>true</strong>;</pre><pre>}</pre><pre>}</pre><pre><strong>if</strong> (swapped == <strong>false</strong>)</pre><pre><strong>break</strong>;</pre><pre>}</pre><pre>}</pre><pre><strong>static void</strong> printArray(<strong>int</strong> arr[], <strong>int</strong> size)</pre><pre>{</pre><pre><strong>int</strong> i;</pre><pre><strong>for</strong> (i = 0; i &lt; size; i++)</pre><pre>System.out.print(arr[i] + &quot; &quot;);</pre><pre>System.out.println();</pre><pre>}</pre><pre><strong>public static void</strong> main(String args[])</pre><pre>{</pre><pre><strong>int</strong> arr[] = { 5,1,4,2,8 };</pre><pre><strong>int</strong> n = arr.length;</pre><pre>bubbleSort(arr, n);</pre><pre>System.out.println(&quot;Sorted array: &quot;);</pre><pre>printArray(arr, n);</pre><pre>}</pre><pre>}</pre><pre><strong>O/P: Sorted array:</strong></pre><pre><strong>1 2 4 5 8</strong></pre><blockquote><strong>When to use Bubble Sorting:</strong></blockquote><blockquote>The idea of almost all languages providing us with the inbuilt sorting algorithms doesn’t let us take a decision on how we want to use sorting into our codes.The Bubble sort works well when it comes to handling any large datasets which are partially in sorted forms. Taking a day to day example of an organisation with employees of different departments and different roles when asked to be sorted, we already have a pre-sorted dataset based on departments or roles with us. So sorting of such datasets can be done using Bubble sorting.</blockquote><blockquote>*<strong>Insertion Sorting</strong></blockquote><blockquote>This sorting is more or less like how any individual intuitively sorts things manually. It works similar to how we sort cards in our hands. Assuming that the first card is always sorted and then we move ahead with selecting an unsorted card and if the card holds a value greater than the card in our hand we place it on right otherwise to the left of the series of cards.</blockquote><blockquote><strong>Working:</strong></blockquote><blockquote>Insertion sorting places an unsorted element at its suitable place with every iteration it makes.To sort an array of size “n” in an ascending order, the algorithm will compare the current element (key element) to its predecessor. If the key element is smaller than the predecessor, it compares it to the elements before it. Moving the greater elements one position up to make space for the swapped elements. To explain it even better; the first element in the array is assumed to be sorted, so we take the second element and store it separately in key. Now we will compare this key with the first element. if the first element is greater than the key, the key gets placed in front of the first element. Now we have first two elements as sorted, taking the third element and comparing it with the elements on the left of it.Place it just behind the element smaller than it, and if there are no elements smaller than it, then place it at the beginning of the array.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*3QRBVHZDfbIDRiLU5gGp7g.jpeg" /><figcaption>pic credit : blogspot.com</figcaption></figure><p><strong>Code Snippet:</strong></p><pre><strong>class</strong> InsertionSorting</pre><pre>{</pre><pre><strong>public void</strong> sort(<strong>int</strong> arr[])</pre><pre>{</pre><pre><strong>int</strong> n = arr.length;</pre><pre><strong>for</strong> (<strong>int</strong> i = 1; i &lt; n; ++i)</pre><pre>{</pre><pre><strong>int</strong> key = arr[i];</pre><pre><strong>int</strong> j = i - 1;</pre><pre><strong>while</strong> (j &gt;= 0 &amp;&amp; arr[j] &gt; key)</pre><pre>{</pre><pre>arr[j + 1] = arr[j];</pre><pre>j = j - 1;</pre><pre>}</pre><pre>arr[j + 1] = key;</pre><pre>}</pre><pre>}</pre><pre><strong>static void</strong> printArray(<strong>int</strong> arr[])</pre><pre>{</pre><pre><strong>int</strong> n = arr.length;</pre><pre><strong>for</strong> (<strong>int</strong> i = 0; i &lt; n; ++i)</pre><pre>System.out.print(arr[i] + &quot; &quot;);</pre><pre>System.out.println();</pre><pre>}</pre><pre><strong>public static void</strong> main(String args[])</pre><pre>{</pre><pre><strong>int</strong> arr[] = { 12, 11, 13, 5, 6 };</pre><pre>InsertionSorting is= <strong>new</strong> InsertionSorting();</pre><pre>is.sort(arr);</pre><pre>printArray(arr);</pre><pre>}</pre><pre>}</pre><pre><strong>O/P: 5 6 11 12 13</strong></pre><blockquote><strong>When to use Insertion Sorting:</strong></blockquote><blockquote>Insertion sorting is generally the fastest solution for sorting smaller units of elements.Insertion sorting takes maximum time to sort if elements are sorted in reverse order. And it takes minimum time (Order of n) when elements are already sorted.</blockquote><blockquote><strong>*Selection Sorting</strong></blockquote><blockquote>This algorithm selects a smallest element from an unsorted list of elements in each iteration and places the element at the very beginning of the unsorted list.</blockquote><blockquote><strong>Working:</strong></blockquote><blockquote>Setting the first element as the minimum element, comparing the second element of the array with this minimum element . If the second element happens to be smaller than the minimum element, the algorithm will assign/ select the second element as the minimum element now. Hence forth, comparing the third element to the (new) minimum element now and again checking if the third element is smaller than the minimum element, if yes, algorithm again will assign the third element as minimum element, else do nothing and shall compare the fourth element to the minimum element. After each iteration that takes place in the algorithm, the minimum element will be placed at the very beginning of the array.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*k2aLcBCZXCMadEfVdA7K_g.png" /><figcaption>pic credit : w3resources.com</figcaption></figure><p><strong>Code Snippet:</strong></p><pre><strong>class </strong>SelectionSort</pre><pre>{</pre><pre><strong>void</strong> sort(<strong>int</strong> arr[])</pre><pre>{</pre><pre><strong>int</strong> n = arr.length;</pre><pre><strong>for</strong> (<strong>int</strong> i = 0; i &lt; n-1; i++)</pre><pre>{</pre><pre><strong>int</strong> min_idx = i;</pre><pre><strong>for</strong> (<strong>int</strong> j = i+1; j &lt; n; j++)</pre><pre><strong>if</strong> (arr[j] &lt; arr[min_idx])</pre><pre>min_idx = j;</pre><pre><strong>int</strong> temp = arr[min_idx];</pre><pre>arr[min_idx] = arr[i];</pre><pre>arr[i] = temp;</pre><pre>}</pre><pre>}</pre><pre><strong>void</strong> printArray(<strong>int</strong> arr[])</pre><pre>{</pre><pre><strong>int</strong> n = arr.length;</pre><pre><strong>for</strong> (<strong>int</strong> i=0; i&lt;n; ++i)</pre><pre>System.out.print(arr[i]+&quot; &quot;);</pre><pre>System.out.println();</pre><pre>}</pre><pre><strong>public static void</strong> main(String args[])</pre><pre>{</pre><pre>SelectionSort ob = <strong>new</strong> SelectionSort();</pre><pre><strong>int</strong> arr[] = {64,25,12,22,11};</pre><pre>ob.sort(arr);</pre><pre>System.out.println(&quot;Sorted array&quot;);</pre><pre>ob.printArray(arr);</pre><pre>}</pre><pre>}</pre><pre><strong>O/P: Sorted array: <br>11 12 22 25 64</strong></pre><blockquote><strong>When to use Selection Sorting:</strong></blockquote><blockquote>Selection algorithm is good at checking if everything is already sorted. It is recommended to be used when we have memory space limitations to be taken care of.</blockquote><p>Hope this article helps you in a little better understanding of the sorting algorithms and their use cases.</p><p>Until next time…</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adf611990c06" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/the-sorting-algorithm-adf611990c06">The Sorting Algorithm!</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Control statements:]]></title>
            <link>https://medium.com/javamadetranquil/the-control-statements-50d642f18cce?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/50d642f18cce</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[control-statements]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Mon, 02 Nov 2020 18:34:31 GMT</pubDate>
            <atom:updated>2020-11-02T18:33:51.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RtHYX0gtQbB68mXntMghDQ.jpeg" /><figcaption><strong>Control statements: the execution flow controllers</strong></figcaption></figure><p><em>As the name suggests, a control statement is a statement which determines whether or not the other statements of a program will be executed. It basically controls the complete flow of a program.</em></p><p>Hello Comrades,</p><p>Today we are looking forward to discussing one of the fundamental topics in any programming language. This article will give you a brief explanation on what are control statements and how they control the flow of execution of any program. Starting with giving you all an overview of the categories of a control statement. The control statement is broadly categorized into three statements</p><ul><li>selection statements[conditional statement/decision making statement]</li><li>iteration statements[looping statement]</li><li>jump statements[branching statement]</li></ul><p><strong><em>Selection statements: </em></strong><em>The selection statements allow the program to test several conditions and execute instructions based on which condition is true. Hence a selection statement is also termed as a </em><strong><em>conditional statement</em></strong><em>. Java typically supports three types of selection statements: single selection statement[if.. statement], double selection statements[if..else statement] and multiple selection statements[switch statements].</em></p><p><strong>if..statement:</strong> The “if ” block gets executed only when the condition is set to true.</p><pre>syntax :<br> if(condition)   <br>   {<br>//statements (if block)<br>   }<br>//other statements</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String [] args){<br> <br>int i =10;<br> <br>if(i&gt;5){<br> <br>System.out.println(&quot;i is greater than 5&quot;); <br> <br>}<br> <br>System.out.println(&quot;i is less than 5&quot;);</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>O/p:</pre><pre>i is greater than 5</pre><p><strong>if..else statement:</strong> The “if ” block gets executed only when the condition is true, otherwise the “ else” block gets executed.</p><pre>syntax: <br>if(condition)<br> {<br>  // statement; (if block statement)<br>   }else{<br>  // statement; (else block statement)<br> }</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String [] args){<br> <br>int i =0;<br> <br>if(i&gt;5){<br> <br>System.out.println(&quot;i is greater than 5&quot;); <br> <br>}else{<br> <br>System.out.println(&quot;i is less than 5&quot;);</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>O/p:</pre><pre>i is less than 5</pre><p><strong>if..else-if statement: </strong>The “if” block gets executed when the condition is true, otherwise the “else-if” block gets executed; and further when condition of “else-if” block is not true, the “else” block gets executed.</p><pre>syntax: <br>if(condition){<br> // statement;(if block)<br>}else if(condition){<br> // statement;(else if block)<br>}else{<br> // statement;(else block)<br>}</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String [] args){<br> <br>int i =100;<br> <br>if(i&gt;5){<br> <br>System.out.println(&quot;i is greater than 5&quot;); <br> <br>}else if(i&lt;5){<br> <br>System.out.println(&quot;i is less than 5&quot;);</strong></pre><pre><strong>}else{</strong></pre><pre><strong>System.out.println(&quot; i is &quot; + i ); //(value of i)</strong></pre><pre><strong>}</strong></pre><pre>O/p:</pre><pre>i is 100</pre><p><strong>switch statement: </strong>The switch statement gives access to the program to select one action[case] among multiple actions[cases] during the execution. If none of the cases match, the default will be executed. It is optional to write “break” statement at the end of each case.</p><pre>syntax:<br>Switch( variable / value/ expression)<br>{<br>Case :<br>//statement[];<br>Case :<br>//statement[];<br>Case :<br>//statement[];<br>Case :<br>//statement[];<br>Case :<br>//statement[];<br>default:<br>//statement[];<br>}</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String[] args){</strong></pre><pre><strong>int number =5; <br>Switch(choice){</strong></pre><pre><strong>case 1:<br>System.out.println(&quot;Number is 1&quot;);</strong></pre><pre><strong>case 3:<br>System.out.println(&quot;Number is 3&quot;);</strong></pre><pre><strong>case 5:<br>System.out.println(&quot;Number is 5&quot;);</strong></pre><pre><strong>case 7:<br>System.out.println(&quot;Number is 7&quot;);</strong></pre><pre><strong>default;<br>Sytem.out.println(&quot;No number is found&quot;);<br>}</strong></pre><pre>0/p:</pre><pre>Number is 5<br>Number is 5<br>No number is found</pre><p><strong><em>iteration statement: </em></strong><em>As the name suggests, these statements executes a block of code in iteration for multiple times, which means it basically runs a block till the looping condition is satisfied. These statement are also broadly classified into for loop, while loop and do-while loop and for-each loop statements.</em></p><p><strong>for loop: </strong>These statements execute until the condition is false. We use these statements, where number of iterations are known to us.</p><pre>syntax:<br>for(initialization, condition, increment/decrement of loop){<br>//statement / block of code(Body)<br>}</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String [] args){</strong></pre><pre><strong>for(int i =0; i&lt;10; i++){</strong></pre><pre><strong>System.out.println(&quot;value of i is : &quot;+i);}// string concatenation</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>o/p: <br>value of i is : 1<br>value of i is : 2<br>value of i is : 3<br>value of i is : 4<br>value of i is : 5<br>value of i is : 6<br>value of i is : 7<br>value of i is : 8<br>value of i is : 9</pre><p><strong>while loop: </strong>This statement executes till the condition sets out to be false, also this while loop executes if and only if the the condition is set to true, unlike do..while loop.</p><pre>syntax: <br>while(condition){<br>//statement<br>}</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String [] args){</strong></pre><pre><strong>int i = 5;</strong></pre><pre><strong>while(i&lt;7){</strong></pre><pre><strong>System.out.println(&quot;value of i is : &quot;+i);}// string concatenation</strong></pre><pre><strong>i++;</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>o/p:<br>value of i is : 5<br>value of i is : 6</pre><p><strong>do..while loop :</strong>Unlike the while loop (which gets executed only if the condition is set to true), a do-while loop executes the loop first and then checks for the condition; which means this do-while loop will execute at-least once.</p><p><strong><em>It has semicolon at the end of the while condition unlike the while loop.</em></strong></p><pre>syntax: <br>do{<br>//statement;<br>while(condition);{<br>//statement;<br>}<br>}</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String [] args){</strong></pre><pre><strong>int a = 2; </strong></pre><pre><strong>do{</strong></pre><pre><strong>System.out.println(&quot;i am in main method&quot;);</strong></pre><pre><strong>}while(a&lt;=2);</strong></pre><pre><strong>System.out.println(&quot;value of i is : + i);</strong></pre><pre><strong> a++;</strong></pre><pre><strong>}</strong></pre><blockquote><strong>Note: do-while loop is called exit controlled loop because they tend to check the condition after the block is executed i.e. they check the condition for exit and if the given condition for exit evaluates to true, control will exit the loop body, else control will enter again into the loop.Such control structure is often referred to as “post-test loop”; whereas for loop and while loop are called entry controlled loop, which tests the condition before the code is executed.</strong></blockquote><p><strong>for-each loop: </strong>The for-each loop or say enhanced for loop provides an alternative approach for traversing the array or collections in Java. It is know as for-each loop as it traverses each element one by one.</p><pre>syntax:<br>for(type  variable : array){<br>//statements utilizing variable;<br>}</pre><pre>e<strong>g: public class abc{</strong></pre><pre><strong>public static void main(String[] args){</strong></pre><pre><strong>int[] a ={100,101,102,103,104,105,106,107,65,98,80,55};</strong></pre><pre><strong>for(int currentInteger : a){</strong></pre><pre><strong>int highestNumberValue = Math.max(a);</strong></pre><pre>Sytem.out.println(&quot;The highest number is : &quot; + <strong>highestNumberValue);</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>o/p: The highest number is : 107</pre><blockquote><strong>Note: The for loop is best for iterating over the name-value pairs where as the for-each loop is best for iterating over values.</strong></blockquote><p><strong><em>jump statements:</em></strong> <em>These statements cause unconditional jumps to other statements elsewhere in the code. Their primary use is to interrupt the switch statements and loops. These are further classified as break statement , continue statement and return statement.</em></p><p><strong>break statement: </strong>As mentioned in the previous article, break is a keyword used within any control statements to terminate the execution of the current loop or any switch cases.</p><pre>syntax:<br>break;<br>break&lt;label&gt;;</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String[] args){</strong></pre><pre><strong>int a =1;</strong></pre><pre><strong>for(int i=0; i &lt; a; i++){</strong></pre><pre><strong>System.out.println(&quot;value of i is : &quot; + i); </strong></pre><pre><strong>if(i==2){</strong></pre><pre><strong>break;</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>o/p:<br>value of i is : 1</pre><p><strong>continue statement:</strong> continue being another keyword is typically used to continue the execution of the current executing loop with next iteration. When a continue statement is encountered in a looping statement, the execution control skips the rest of the statements in the looping block and directly jumps to the beginning of the loop. When used with a while and do-while loop statements, the execution control directly jumps to the condition, where as when used with for statement, the continue statement directly jumps to the modification(increment / decrement) of the for loop.</p><pre>syntax:<br>continue;<br>continue&lt;label&gt;;</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>public static void main(String[] args){</strong></pre><pre><strong>int a =1;</strong></pre><pre><strong>for(int i=0; i &lt; a; i++){</strong></pre><pre><strong>System.out.print(&quot;value of i is : &quot; + i);</strong></pre><pre><strong>if(i==2)continue;</strong></pre><pre><strong>System.out.println(&quot;class abc&quot;);</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre>o/p:<br>value of i is : 1 class abc<br>value of i is : 2 3 class abc</pre><p><strong>return statement:</strong> The return statement terminates the execution of a method and returns control to the calling method, with or without any return value[ based on the return type of the method is set to void or not]. A return statement cannot appear in a method whose return type is void.</p><pre>syntax:<br>return expression(optional);</pre><pre><strong>eg: public class abc{</strong></pre><pre><strong>static int a = 10;</strong></pre><pre><strong>public static void main(String... args){</strong></pre><pre><strong>System.out.print(&quot;in main method&quot;);</strong></pre><pre><strong>add(6);</strong></pre><pre><strong>System.in.println(&quot;executed add method&quot;);</strong></pre><pre><strong>sub(2);</strong></pre><pre><strong>System.in.println(&quot;executed sub method&quot;);</strong></pre><pre><strong>}</strong></pre><pre><strong>public static int add(int i){</strong></pre><pre><strong>int j = a+i;</strong></pre><pre><strong>System.out.println(&quot;in add method&quot;);</strong></pre><pre><strong>return j;</strong></pre><pre><strong>}</strong></pre><pre><strong>public static void sub(int i){</strong></pre><pre><strong> a-i;</strong></pre><pre><strong>System.out.println(&quot;in subtract method&quot;);</strong></pre><pre><strong>}</strong></pre><pre><strong>}</strong></pre><pre><strong>}<br>o/p:<br>in main method<br>in add method<br>executed add method<br>in subtract method <br>executed sub method</strong></pre><p>That is it on this article from my end. For any queries pr suggestion you can reach me <a href="https://www.linkedin.com/in/rupam-pawan-jha-151313a7/">here</a>.</p><p>Until next time…</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50d642f18cce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/the-control-statements-50d642f18cce">The Control statements:</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Datatypes, Variables and Modifiers in Java:]]></title>
            <link>https://medium.com/javamadetranquil/datatypes-variables-and-modifiers-in-java-df7b2c83be6b?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/df7b2c83be6b</guid>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Wed, 28 Oct 2020 18:34:58 GMT</pubDate>
            <atom:updated>2020-10-28T18:33:56.635Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKluKmusYNmShi9Wnd4xRg.jpeg" /><figcaption><strong>Variables, Data types and Modifiers</strong></figcaption></figure><p>I have assembled these topics into this single article, as they are interlinked with each other’s definitions and hold better explanations when put together. Also I as a publisher would never like my readers to remain in any sort of a dilemma while reading the articles which I intend to write to make things and concepts look little lesser complex to you all out there.</p><p>Hello Comrades,</p><p>So to begin with, let us understand a basic terminology of what these words actually mean, and as we proceed further we will dive deep into their classifications and usages in Java.</p><p><strong>Variables :</strong></p><p>A <strong>variable </strong>is basically a <strong>container which holds the value</strong> while any Java program gets executed. These are nothing but reserved memory locations to store values, which means that when you create any variable you reserve some space in the memory.<strong> </strong>A variable is the basic unit of storage in a program.<strong> It is always assigned with a data type to it</strong>. <strong>Data types</strong> defines <strong>values that any variable can take.</strong></p><blockquote><strong>Note: The value that we store in a variable can be changed during the execution of program as per the modifiers they are used with. A variable is the only name given to the memory locations and any operation done with the variables actually effects the memory locations. Java is a statically typed language. By statically typed language I mean, the data type of the variable is known at compile time[while writing a code], which further means we have to specify the type of variable before we could even use it.</strong></blockquote><p><strong>Declaration of a variable:</strong></p><p>In Java the variables are declared before they can be used.</p><p><strong>eg: int a = 100;</strong></p><p>here <strong>int</strong> refers to the <strong>datatype</strong></p><p><strong>a </strong>refers to the <strong>name </strong>of the variable</p><p><strong>100 </strong>refers to the <strong>value </strong>assigned to it.</p><p><strong>Variable naming convention:</strong></p><ul><li>Variable name should not contain any white spaces.</li><li>Variable name can begin with special characters like _ and $</li><li>Variable name is recommended to start with small characters.</li><li>Variable names are case sensitive.</li></ul><p><strong>Types of Variables :</strong></p><p>There are <strong>four types of variables</strong> in Java.</p><ul><li><strong><em>Instance variables[Non-Static variables] :</em></strong></li></ul><p>These variables are defined without the “static” keyword. They are defined outside a method declaration. They are specific to the objects of the class, and hence are known as Instance[object] variables. Each instance [object] of a class has its own copy of a instance variable.</p><ul><li><strong><em>Class variables [Static variables]:</em></strong></li></ul><p>These variables are initialized only once at the beginning of the program execution. These are defined with “static” keyword. This tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class is been instantiated [no matter how many times objects are made of that class].</p><ul><li><strong><em>Local variables:</em></strong></li></ul><p>These are the variables specific to any single method as they are declared within a method. Their scope is limited to the method which means that we cannot access these variables outside a method.</p><ul><li><strong><em>Parameters:</em></strong></li></ul><p>The parameters of a method are always classified as a variable and not as fields. eg. public static void abc(<strong>int a</strong>).</p><p><strong>Data types:</strong></p><p>The datatypes are defined as specifiers which specify and allocate different sizes and types of values that can be stored in the variables.</p><p><strong>Types of data types:</strong></p><ul><li><strong><em>Primitive data type: [integer, character, boolean, float]</em></strong></li></ul><p>These are predefined data types that are already present in Java language. There are 8 primitive data types categorized into 4 sub types as : <strong>Integer data</strong> <strong>type</strong>[byte[1 byte], short[2 bytes], int[4 bytes], long[8 bytes]], <strong>floating data type</strong>[float[4 bytes], double[8 bytes]], <strong>textual data type</strong>[char[2 bytes]], <strong>logical data type</strong>[boolean[1 byte]].</p><ul><li><strong><em>boolean data type: </em></strong><em>A boolean data type comprises of a bit of information which can store either true or false values. This data type usually tracks true/false conditions.</em></li><li><strong><em>byte data type:</em></strong><em> A byte data type comprises of a 8-bit signed two’s compliment integer, storing value ranging from -128 to 127.</em></li><li><strong><em>char data type:</em></strong><em> A char data type is used when we have to store a single character , enclosed within a single quote. We can use ASCII values too to display these characters.</em></li><li><strong><em>short data type:</em></strong><em> A short data type is greater than a byte in terms of size and less than that of an integer, storing range from -32,768 to 32,767.</em></li><li><strong><em>int data type:</em></strong><em> An int is a preferred data type when we create a variable with numeric value assigned to it. It stores values ranging from -2147483648 to 2147483647.[ not recommended to be memorized]</em></li><li><strong><em>long data type:</em></strong><em> A long data type comprises of a 64-bit two’s complement integer ranging from -2⁶³ to 2⁶³ -1.</em></li><li><strong><em>float data type:</em></strong><em> A float data type comprises of storage of fractional numbers. The value of a float data type should always end with ‘f’. eg. float a = 10.7f;</em></li><li><strong><em>double data type: </em></strong><em>A double data type comprises of storage of fractional numbers. The value should always end with ‘d ’. eg. double a = 10.7d;</em></li></ul><blockquote><strong>Note: The size of the data types remains same on all platforms[32-bit / 64-bit]</strong></blockquote><ul><li><strong><em>Non-Primitive data type:[strings, classes, arrays, interfaces]</em></strong></li></ul><p>These are not actually defined by the programming language but are rather created by programmers / developers, also termed as “reference variables” or “object references”.</p><ul><li><strong><em>Strings:</em></strong><em> A string is an object that represents sequence of characters.</em></li><li><strong><em>arrays:</em></strong> <em>An array stores one or more values of a specific data type there by providing indexed access to the elements of an array.</em></li><li><strong><em>classes:</em></strong><em> It is termed as a blueprint that composes of all the data. A class contains variables , methods, constructors, that describes the behavior of an object in it.</em></li><li><strong><em>interfaces</em></strong><em>: Like a class even interfaces comprises of methods and variables , but the methods are abstract [by default] i.e. no implementation within the body of a method.</em></li></ul><p><strong><em>The basic difference between Primitive and Non-Primitive data types:</em></strong></p><ul><li>Primitive data types are predefined whereas Non-Primitive are programmer defined.</li><li>Primitive data types cannot hold null values to it, but Non- Primitive can hold null values to it.</li></ul><p><strong>Modifiers:</strong></p><p>Access modifiers are keywords in any object oriented programming languages that <strong>set accessibility of classes, methods and other members.</strong> They <strong>facilitate the encapsulation of components</strong>. In other words, they help restrict the scope of a class, constructor, variable, method or data member. The modifiers are further grouped into two sections based on their functionalities as Access modifiers and Non-access modifiers.<strong> </strong>Access modifiers are used to <strong>control the visibility </strong>of a class or a variable or a method, where as non- access modifiers are used to provide other functionalities like<strong> synchronizing</strong> a method or a block, <strong>restricting serialization</strong> of any variable etc.</p><p><strong>Types of access modifiers:</strong></p><ul><li><strong><em>private:</em></strong><em> private members of a class be it any method or a constructor, they cannot be access outside of a class in which they are defined, not even to their sub classes.</em></li><li><strong><em>public: </em></strong><em>public members are visible to all the packages and all the class and sub classes in any packages.</em></li><li><strong><em>default:</em></strong><em> default members are actually with no access modifier and are visible anywhere within a package. They are visible to their sub classes within the package.</em></li><li><strong><em>protected: </em></strong><em>protected members hold half the characteristics of the public members and half of default members. i.e. they are visible within package like default members and visible to their sub classes like public members.</em></li></ul><p><strong>Types of Non- access modifiers:</strong></p><ul><li><strong><em>static: </em></strong><em>The members declared static becomes common for all the instances[objects] of the class. These are basically class level members and are stored in class memory.</em><strong><em> It makes any class member independent of any object of that class.</em></strong></li><li><strong><em>final:</em></strong><em> The members declared final becomes restrictive to any further modifications in the variable, method or a class. The value of variable declared as final cannot be modified further.The method declared as final cannot be overridden by any sub classes we cannot create any sub class of a class declared as final[i.e. we cannot inherit any final class]</em></li><li><strong><em>abstract: </em></strong><em>Either a class or a method can be declared as abstract. No variable or constructor can be declared as abstract. A method declared as abstract has to be modified[implemented] in any of its sub classes, and we cannot instantiate[create an object] of any abstract classes. </em><strong><em>The abstract modifier is heavily used with the concept of polymorphism.</em></strong></li><li><strong><em>synchronized:</em></strong><em>When two or</em><strong><em> </em></strong><em>more threads needs to access a same resource, we somehow need to make sure that only one of the thread get the access at a time, and in order to achieve so, we need to synchronize them. A method or a block declared as synchronized becomes accessible by only one thread at a time in any multi threaded environment. S</em><strong><em>ynchronization is a strategy or a method to avoid thread interference hence protecting data from inconsistency. </em></strong><em>Synchronization in Java is built around an entity called as “ object lock or monitor”.</em></li><li><strong><em>transient:</em></strong><em> The modifier is basically used in a process called serialization. A variable declared as transient will not be serialized during the object serialization. Serialization is a process of converting state of an object to byte stream which can be persisted in to a disk /file or sent over a network to any other running JVMs.</em><strong><em> Its main purpose is to save the state of any object in order to be able to re create it when needed</em></strong><em> [reverse process is called de-serialization]</em></li><li><strong><em>volatile:</em></strong><em> If any variable is marked as volatile, it indicates that the state of the variable can change its value between different accesses among’st various threads . In order to better understand “volatile” we need to know a little about how the memory works? Usually, a variable’s value is stored in the main memory [RAM] but so as to boost the performance, the processor may store the value in its cache [L1, L2,L3 caches]. In this case, any change in the value is written back to the main memory only when the cache synchronizes with the main memory. Now if a variable is declared as volatile, the compiler [even runtime] seeing this “volatile” keyword knows that this variable is shared and hence volatile variables are never cached in registers and the read operations on these variables returns the most recent write by any thread.</em></li><li><strong><em>strictfp: </em></strong><em>This modifier is used for any </em><strong><em>floating point calculations</em></strong><em>. It ensures that we get same calculation results on every platform.</em></li></ul><p>That is it on this article about data types, variables and modifiers in Java. for any further clarification please drop in your queries or suggestion in the comment below. I hope this article was worth your time.</p><p>Until next time!</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df7b2c83be6b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/datatypes-variables-and-modifiers-in-java-df7b2c83be6b">Datatypes, Variables and Modifiers in Java:</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keywords in Java:]]></title>
            <link>https://medium.com/javamadetranquil/keywords-in-java-8bd839a87287?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/8bd839a87287</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[keywords]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Sat, 17 Oct 2020 10:22:05 GMT</pubDate>
            <atom:updated>2020-10-15T05:13:47.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcHAlwU1hTNoqhM9HiOj-g.jpeg" /><figcaption><strong>Keywords : a reserved word holding a predefined meaning to it!</strong></figcaption></figure><p>Hello Comrades,</p><p>As we have gathered to feed on some very basic yet another important topic today, lets do the talking about <strong>what a Keyword in Java is? </strong>… let us understand that a <strong><em>keyword is precisely any reserved word that holds a specific predefined meaning to it in a language.</em></strong></p><p>I will be mentioning here the list of Java Keywords.<em>[tip: don’t try memorizing this stuff, its just for making you familiar with what are their usages]</em></p><ul><li>abstract</li><li>assert</li><li>boolean</li><li>break</li><li>byte</li><li>case</li><li>catch</li><li>char</li><li>class</li><li>count(unused)</li><li>continue</li><li>default</li><li>do</li><li>double</li><li>else</li><li>enum</li><li>extends</li><li>final</li><li>finally</li><li>float</li><li>for</li><li>goto(unused)</li><li>if</li><li>implements</li><li>import</li><li>instanceof</li><li>int</li><li>interface</li><li>long</li><li>native</li><li>new</li><li>package</li><li>private</li><li>protected</li><li>public</li><li>return</li><li>short</li><li>static</li><li>strictfp</li><li>super</li><li>switch</li><li>synchronized</li><li>this</li><li>throw</li><li>throws</li><li>transient</li><li>try</li><li>void</li><li>volatile</li><li>while</li></ul><ol><li><strong>abstract</strong>: It is a Java keyword applicable to class and methods. <strong>We cannot create an Object of an abstract class.</strong> The abstract keyword is recommended to be placed after the access modifier <strong>static</strong>. An abstract class cannot be <strong>final</strong>. If a method is declared as abstract, it will have only declaration of it and no implementation written in it. An abstract method cannot be <strong>private</strong>, <strong>final</strong>, <strong>static </strong>or <strong>native</strong>.</li></ol><blockquote><strong>valid </strong>abstract <strong>class </strong>representation:</blockquote><blockquote>public static abstract int classA{};</blockquote><blockquote><strong>invalid </strong>abstract <strong>class </strong>representation:</blockquote><blockquote>public final abstract int classA{};</blockquote><blockquote><strong>invalid </strong>abstract <strong>method </strong>representation:</blockquote><blockquote>private static final native abstract int methodA(){};</blockquote><p><strong>2. assert:</strong> It provides definition to the assert statements. A statement is said to be an assert statement when it declares an expected boolean condition in a program. It allows us to test the correctness of any assumptions that the program has. If any program running with assertion enabled, its condition will be checked at runtime and if its condition is false, JVM will throw “AssertionError” and if its condition is true, it does nothing. To configure assert, we can use command line flags i.e. the -ea or the -da [to enable or disable] using a command line tool.</p><blockquote>valid assert representation :</blockquote><blockquote>assert exp1 [:exp2]; i.e. exp1 is a boolean, that might throw assertion if its false. When an assertion is thrown , it creates AssertionError exception along with the parameter exp2.</blockquote><p><strong>3.</strong> <strong>boolean:</strong> It is a Java keyword which allocates either of the two values; true or false. By default its value is set to false. It can be used with a variable, method parameters and method return types. The size of the boolean depends on JVM as it is not precisely defined.</p><blockquote><strong>valid boolean representations:</strong></blockquote><blockquote>boolean isAlligned = false; →<strong>representing a variable</strong></blockquote><blockquote>public void setAlignment(boolean align){}; →<strong>representing a method parameter</strong></blockquote><blockquote>public boolean isAligned(){};→<strong>representing a method return type</strong></blockquote><p><strong>4. break</strong> : It is a Java keyword which terminates the execution of a for loop, while loop or a do-while loop condition thereby allowing the program to execute to the next steps. Using of a break keyword, refers to a “break statement”. A break statement helps us to exit from any block of code. They are of two forms namely<strong> Unlabeled break statement</strong> and L<strong>abeled break statement</strong>. The unlabeled break statements are without any labels, where as the labeled break statements holds a label name after the break statement.[as mentioned in egs. below]</p><blockquote><strong>A] Unlabeled break statement:</strong></blockquote><blockquote>int i =1;</blockquote><blockquote>while(true){</blockquote><blockquote>if(i&lt;10){</blockquote><blockquote>System.out.println(“Number is : ”+ i);</blockquote><blockquote>i++;</blockquote><blockquote>}else{</blockquote><blockquote>break;</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote><strong>B] Labeled break statement:</strong></blockquote><blockquote>blocklabel{</blockquote><blockquote>int i =10;</blockquote><blockquote>if(i==5){</blockquote><blockquote>break blocklabel;</blockquote><blockquote>}</blockquote><blockquote>if(i==10){</blockquote><blockquote>System.out.println(“Number is : ” +i);</blockquote><blockquote>}</blockquote><p>here, the break statement will eventually terminate the labeled statement and shall not transfer the flow of control to the label[blocklabel here]. Control is transferred to the statement immediately following the labelled statement.</p><p><strong>5. byte:</strong> A 8 bit signed integer primitive type is designated to a byte keyword.</p><p><strong>6. case:</strong> It is a Java keyword which is a part of a switch statement, to find if the value passed matches the value followed by any case. [mentioned in eg. below]</p><blockquote>int i =5;</blockquote><blockquote>switch(i){</blockquote><blockquote>case 1:</blockquote><blockquote>System.out.println(“number is : 1 ” );</blockquote><blockquote>break;</blockquote><blockquote>case 3:</blockquote><blockquote>System.out.println(“number is : 1 ” );</blockquote><blockquote>break;</blockquote><blockquote>case 5:</blockquote><blockquote>System.out.println(“number is : 1 ” );</blockquote><blockquote>break;</blockquote><blockquote>default:</blockquote><blockquote>System.out.println(“number is not 1,3,5” );</blockquote><blockquote>}</blockquote><p><strong>7.catch:</strong> It is a Java keyword which is a part of try block. It is an exception which is thrown by the try block which later is compared to any exception type declared in this catch block and if the exception matches to the exception type present in the catch block , the exception gets handled.[we will discuss in detail on this in the upcoming articles].</p><p><strong>8.char: </strong>It is a Java keyword which defines the primitive datatype character.</p><p><strong>9.class: </strong>It is a Java keyword which begins the declaration and definition of a Java class.</p><p><strong>10.const: </strong>It is a <em>reserved </em>keyword which are currently not being used. But is used to declare a constant in other languages like C++.</p><p><strong>11.continue: </strong>It is a Java keyword which skips the current condition of the loop and continues with the next iterations.[mentioned in eg.]</p><blockquote>int a =6;</blockquote><blockquote>for(int i =0;i≤a;i++){</blockquote><blockquote>if(i==3){</blockquote><blockquote>continue;</blockquote><blockquote>}</blockquote><blockquote>System.out.print(“iteration = ”+i);</blockquote><blockquote>}</blockquote><blockquote><strong>o/p =0 1 2 4 5 6</strong></blockquote><p><strong>12. default:</strong> It is a Java keyword in Java which the optional part of a switch statement and gets executed only when none of the case is matched.</p><p><strong>13.do:</strong> It is a Java keyword which is a part of a do-while loop. The statement present within the do block always gets executed.</p><p><strong>14.double: </strong>It is a Java keyword which stores the primitive data type 64-bit double’s value into it.</p><p><strong>15.else:</strong> It is a Java keyword which is a part of a branching statement and gets executed only when the if condition is stated as false.</p><p><strong>16.enum:</strong> It is a special class in Java, which represents a group of constants. It is also a Java keyword used to create enum class.</p><p><strong>17.extends: </strong>It is a Java keyword used in a class or an interface definitions. Basically if any class or an interface extends[tries using methods or variables from a parent class] some class or interface it uses the extends keyword.</p><p><strong>18.final: </strong>It is a Java keyword which is used for a class, a method, or a variable. <strong><em>If used for a class, we cannot inherit that class. If used for a method we cannot override that method and if used for a variable, we cannot change its value throughout the program execution.</em></strong></p><p><strong>19.finally:</strong> It is a Java keyword which is an optional part of try-catch block. The line of code present inside the finally block will always get executed no matter if the try block either has thrown an error or has a return statement. But in case any exception which happens before the try-catch block then finally block is not executed. If any return statement is used inside the finally block , it will always override the return method of the try-catch block.</p><p><strong>20.float: </strong>It is a keyword designated to a 32-bit float primitive datatype.</p><p><strong>21.for:</strong> It is a Java keyword used in a looping statement. It initiates the iteration from any mentioned range with in its parameter[ mentioned eg.]</p><blockquote>for(int i -0; i&lt; 10; i++){</blockquote><blockquote>System.out.println(“number is ” +i);</blockquote><blockquote>}</blockquote><p><strong>22.goto: </strong>It is reserved keyword currently not being used. It was used to jump out of a loop. As we have an alternative to it : labeled break statement, we don’t use it anymore.</p><p><strong>23.if: </strong>It is a Java keyword used in a branching statement. It gets executed only when the <strong>if conditions</strong> are true.</p><p><strong>24. implements: </strong>It is a Java keyword used to declare if an interface is being implemented by a class.</p><p><strong>25.import:</strong> It is a Java keyword which is used to access all the Java classes and packages for the code written in any program.</p><p><strong>26.instanceOf: </strong>It is a Java keyword which checks if an object reference is an instance of the type and returns true if the type matches.[mentioned eg.]</p><blockquote>Apple instanceOf(Fruit);</blockquote><p><strong>27.int:</strong> It is a Java keyword which is designated to 32-bit primitive datatype integer.</p><p><strong>28.interface:</strong> It is a Java keyword which is used to declare a Java Interface.</p><p><strong>29.long: </strong>It is a Java keyword which is designated to a 64-bit signed integer primitive datatype.</p><p><strong>30.native:</strong> It is Java keyword which marks a method which is implemented in any other language other than Java. <strong><em>The method will be without a body and cannot be abstract. </em></strong>It works along with JNI(Java Native Interface). The use of a <strong><em>native method was to write performance critical sections.</em></strong></p><p><strong>31.new: </strong>It is a Java keyword which creates a new object and allocates the memory for the object on heap.</p><p><strong>32.package:</strong> It is a Java keyword which declares a namespace for a Java class. It has to be the first Java Statement line in any program.</p><p><strong>33.private:</strong> It is an access modifier which declares a member’s access as private i.e. the member will be visible only within the class and not from any other class(sub-classes).</p><p><strong><em>accessibility : Only within class</em></strong></p><blockquote><strong>Note: As access modifiers are not handled at instance (object)levels but are handled at class levels, private members can be visible from other instances(objects) of the same class.</strong></blockquote><p><strong>34.protected: </strong>It is also an access modifier which is used for a method or a class member to mention that the variable or method can only be accessed by the elements residing in its own class in the same package and also from the sub-classes of it in either the same package or a different package.</p><p><strong><em>accessibility : within class, sub-classes and packages</em></strong></p><p><strong>35.public:</strong> It is also an access modifier which helps declare a member’s access publicly. i.e. visible to all classes.</p><p><strong><em>accessibility : within class, sub-classes ,packages and outside packages</em></strong></p><blockquote>Note: A best practice is always to give the<strong> fields a private access </strong>and reserve the<strong> public access to the methods </strong>thereby giving all the <strong>public constants a final access modifier. </strong>This enables<strong> encapsulation and information hiding; </strong>as it allows us to change the implementation of the class without affecting the customer using the public APIs.</blockquote><p><strong>36.return:</strong> It is a Java keyword which returns the <strong><em>Object’s reference and not the Object’s value.</em></strong></p><p><strong>37.short: </strong>It is a Java keyword designated to a 16 bit signed integer primitive type.</p><p><strong>38.static: </strong>The <strong><em>prime function of the static keyword is memory management. </em></strong>It is a non-access modifier which can be used for any method, a variables, blocks or an inner class[nested classes]. The main() method of every class is generally labelled as static. When any member of a class is declared as static, it can be accessed before the object of the class is created as it doesn’t require any object reference to call it.</p><blockquote><strong>Note: If a block is made static it gets executed only once and is initialized when the class is firstly loaded. If a variable is declared as static, it holds a single copy of itself among’st all the objects of that class. They can be created at a class-level only. If a method is declared as static,it can access the static data directly and can call the other static methods only. If a class is declared as static, it has to be only a nested class[a class within a class].</strong></blockquote><p><strong>39.strictfp: </strong>It is a Java Keyword which is used to <strong>restrict the floating point calculations </strong>there by ensuring same result on every platform [be it any of the 16-bit/32-bit/64-bit platform]while performing operations on floating -point variables.</p><blockquote><strong>Note: It is to be used with classes, interfaces and methods only. If a class or an interface is declared strictfp, then all the underlying method of the class or interface are implicitly made strictfp. It cannot be used with an abstract method,but can be used along an abstract class or interfaces. As methods of an interface are abstract in nature implicitly, hence strictfp cannot be used for any methods inside of an interface.</strong></blockquote><p><strong>40.super</strong>: It is a Java keyword used inside a sub-class[child class] method definition to call any methods of its parent[super] class. If any method is declared as private in parent class, then its child class cannot access it using super keyword. It also is been used in constructors to call the parent[super] constructor. It cannot be used along an static method.</p><p><strong>41.switch:</strong> It is a Java Keyword used for a branching statement, based on a numeric value which can be either of a char type, a byte type, a short type or int type.[mentioned in eg. below]</p><blockquote>switch(3){</blockquote><blockquote>case 1:</blockquote><blockquote>System.out.println(“number is 1”);</blockquote><blockquote>break;</blockquote><blockquote>case 2:</blockquote><blockquote>System.out.println(“number is 2”);</blockquote><blockquote>break;</blockquote><blockquote>case 3:</blockquote><blockquote>System.out.println(“number is 3”);</blockquote><blockquote>break;</blockquote><blockquote>case 4:</blockquote><blockquote>System.out.println(“number is 4”);</blockquote><blockquote>break;</blockquote><blockquote>default:</blockquote><blockquote>System.out.println(“number is neither 1,2,3,4”);<br>}</blockquote><p>when the integer value mentioned in switch() matches one of the mentioned case labels, then the statements of that specific case is executed, including the following labels’ statement ,until the end of switch block or until a break keyword is reached.</p><p><strong>42.synchronized: </strong>A scenario of multi threading occurs where multiple threads try to access a same resource there by producing an erroneous output. So Java has introduced a concept of synchronization where we can <strong><em>acquire a lock on the resource that can be used by multiple threads.</em></strong> By either creating a synchronized block or by marking a method as synchronized.</p><blockquote><strong>Note: The synchronization is always associated to an object. If the method is static the associated object here is the class, i.e. a static synchronized method will lock the class instead of an object.</strong></blockquote><p><strong>43.Singleton:</strong> It is a keyword used for a class. If a class is declared as singleton, only one instance[object] will be created of that class at a time[we will discuss in detail on this in the upcoming articles].</p><p><strong>44.this: </strong>It is a Java keyword which contains the current object reference. Basically used to pass the current object as a parameter to any method.</p><p><strong>45.throw:</strong> It is a Java keyword which is a<strong><em> part of a try- catch block.</em></strong> It throws an exception[we will discuss in detail on this in the upcoming articles].</p><p><strong>46.throws:</strong> It is a Java keyword which is <strong>used in the method definition</strong> to declare the exception to be thrown by a method.</p><p><strong>47.transient:</strong> It is a Java keyword which <strong><em>marks the variables not to be serialized. </em></strong>When an object is transferred through the network, the object gets serialized[ converts its state from object to streams of byte], and then are transmitted across the network. The member variables marked as transient don’t get transferred across the network and are intentionally made lost [we will discuss in detail on this in the upcoming articles].</p><p><strong>48.try: </strong>It is a Java keyword which initiates the try block. If an exception is occurred in this block it gets compared to the exceptions present in the catch block.</p><p><strong>49.void:</strong> It is a Java keyword used at a method declaration and definition to assure the method does not return any type.</p><p><strong>50.volatile: </strong>It is a Java keyword used to mark a member variable as volatile i.e.<strong><em> being stored in a memory and not in cache</em></strong>. It is yet another way to make a class thread-safe. i.e. the keyword volatile tells the compiler that the value of the variable must never be cached as its value might change outside the scope of the program[we will discuss in detail on this in the upcoming articles].</p><p><strong>51.while: </strong>It is a Java keyword used in starting a looping block of code. It is used in while loop and do-while loop conditions.</p><p>Hope this article was worth your time investing reading it!!!</p><p>That is it on this article from my end, for any further detailed information needed on any of the keywords , kindly comment in the sections and I shall be privileged answering them.</p><p>Until then….</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bd839a87287" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/keywords-in-java-8bd839a87287">Keywords in Java:</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[General article on how a Heap memory works and role of a Garbage Collector in it!]]></title>
            <link>https://medium.com/javamadetranquil/general-article-on-how-a-heap-memory-works-and-role-of-a-garbage-collector-in-it-9dca0c5b7411?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/9dca0c5b7411</guid>
            <category><![CDATA[heap]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[knowledge-sharing]]></category>
            <category><![CDATA[garbage-collection]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Sat, 17 Oct 2020 10:21:34 GMT</pubDate>
            <atom:updated>2020-10-17T10:17:54.461Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCZsfg-CaukDOzHyrhuCOw.jpeg" /><figcaption><strong>Heap memory — the dynamic memory allocation</strong></figcaption></figure><p>Today while being interviewed as a candidate for a SDE II role in a reputed organization, I was asked a very simple yet another important question for what do you know about a <strong><em>heap memory and Garbage collection in Java?</em></strong> Although I was fairly able to explain the concept, a thought prevailed for letting you all know about what a heap memory is and what should you typically answer it like, when questioned in an interview!</p><p>Hello Comrades,</p><p>To begin with, irrespective of you being aware or unaware of what does Java Heap Memory actually functions like. I would like to draw your attention towards what is the functionality of a Heap memory and what is Memory management in Java? <strong>Memory management is basically a process of allocating new objects and removing the unused objects[using Garbage Collection] properly.</strong> Java has an <strong>automatic memory management</strong> called <strong>Garbage collector</strong> that works in background to clean up the unused or say unreferenced objects and keeps freeing up the memory. There is a huge amount of memory in JVM which is divided into the Stack and Heap memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*NcnxNMngvjodtXzSdowolA.jpeg" /><figcaption><strong>Heap Memory segments</strong></figcaption></figure><p><strong><em>Why Heap memory</em></strong>! When it comes to <strong><em>dynamically allocating a memory,</em></strong> all that you got to think about is the heap memory. A heap memory is basically used for a dynamic memory allocation [i.e. the program can ‘<strong>request</strong>’ and ‘<strong>release</strong>’ memory from the heap segment whenever it is required] of Java objects and JRE classes at the runtime. Any new object is always been created in Heap memory and the references to this objects are stored in stack memory. The objects are given global access i.e. can be accessed from anywhere in the application. A memory allocated to the heap lives until one of the mentioned events occurs:</p><ul><li>Program termination</li><li>Memory freed</li></ul><p>The Heap memory is divided into the two main generations stated as<strong> Young generation</strong> and <strong>Old generation.</strong> The first part of the Young generation is called as <strong>Eden space</strong> and the second part is called as<strong> Survivor space</strong> consisting of <strong>Survivor I</strong> and <strong>Survivor II</strong>. As we understood the different segments present in Young generation, let us understand what is the purpose of these segments.</p><p><strong>The Young generation:</strong></p><p>The moment any new object is created, the object moves into the Eden space first. Now, if the application is heavy and creates an ample of objects, in this case the Eden memory gets filled up with objects, here the Garbage collector pops in and clears up all the unused objects and this process is termed as <strong>Minor GC</strong>. This Minor GC will further move all the survivor objects[the objects in Eden space which still holds reference] to the Survivor memory space. Minor GC has performed automatically on Young Generation to free up the memory space. As we have so many objects being created for so many classes, so when the no. of object increases, the memory in the Eden space also increases. Minor GC works at a faster rate hence takes lesser time to perform. The Objects that survived in the Young generation are now moved to the Old generation.</p><p><strong>The Old generation:</strong></p><p>As the Old generations starts getting filled up with all the survivor objects, the <strong>Major GC</strong> is triggered for freeing up the space by clearing the unused or unreferenced objects from the Old generation. The Major GC takes a lot of time to perform freeing up the space.</p><p>The PermGen [Permanent Generation]:</p><p>This is been discarded in JDK version 8 and above. The PermGen is a special heap space, separated from the main heap memory. All the<strong> static variables and constants</strong> that we create gets stored in <strong>Method area, </strong>and Method area<strong> </strong>is a part of PermGen. The disadvantage about the PermGen is that it holds very limited memory size and thus if this space is filled we get <strong>OutOfMemoryError. </strong>When the <strong>class loaders</strong> in PermGen is not Garbage collected adequately , it leads to<strong> Memory leakage.</strong></p><p><strong>Metaspace </strong>is the new memory space which<strong> </strong>has replaced the PermGen from JDK 8 onward. This grows its memory allocations automatically by default as per the requirement. <strong>The advantage of the metaspace in JDK 8 is that the garbage collector automatically triggers the removal of the dead classes once the class metadata reaches its maximum size, there by reducing the chances of throwing OutOfMemoryError.</strong></p><p>The default size of the heap memory is 128MB on most of the 32 bit devices, but it varies from JVM to JVM. <strong>Java Heap Dump </strong>is a snapshot of Java Heap memory, useful to analyze or troubleshoot any memory leak in Java.</p><blockquote><strong>Note: The Garbage collector collects only those objects that are created using ‘new’ keyword. So if you have created any object without using the new keyword you can perform its cleanup in the finalize()method block. Finalize() method is invoked each time before the object is garbage collected.</strong></blockquote><p><strong>The Garbage collector:</strong></p><p>What is Garbage collection? <strong><em>It is a process of analyzing which objects are holding references and which objects are unused in Java Heap memory thereby deleting the unused objects. Garbage collector is considered as a Heart of Core Java.</em></strong></p><p>The two primary measures of a GC performance are:</p><ul><li><strong>throughput</strong>: It is the percentage of total time not spent in garbage collection. It refers to the amount of productive task done by our application in a given period of time[ eg. no. of database queries that can be completed over a period of time, or no. of transactions completed].</li><li><strong>pause-time[latency]: </strong>Also known as <strong>Stop-the- world-event</strong>, denotes how long an application pauses or say remains unresponsive due to Garbage collection operation being performed.</li></ul><blockquote><strong>Note: Garbage collection is performed by a daemon thread called GC. This thread calls the finalize() method before object is garbage collected.</strong></blockquote><p><strong>Daemon thread: </strong>These are low priority threads which runs intermittently in background for Garbage collection. Thread Scheduler schedules these threads when CPU is idle. These threads are service oriented threads as they serve all the other user threads. They get created before other user threads and die after all the user threads. JVM terminates itself when all the user threads are done with their execution, JVM does not care weather a daemon thread is still running or not, if JVM finds any running daemon thread(upon completion of the user threads), it terminates the daemon thread and after that shutdowns itself. All the user created threads are non-daemon threads and in order to make any thread as a daemon thread we use setDaemon() method.</p><p><strong>Types of Garbage collector: </strong>To be very precised about the Garbage collector types, we have most commonly used ones as mentioned below:</p><ul><li>Serial Garbage Collector</li><li>Parallel Garbage Collector[throughput collector]</li><li>CMS collector[Concurrent Mark Sweep]</li><li>G1 Garbage Collector[Garbage First]</li></ul><p><strong><em>Serial Garbage Collector: </em></strong>It is designed for a single threaded environment. Both the Minor GC and Major GC is done serially one after the other using single virtual CPU. It internally uses<strong> <em>“Mark Compact Collection Algorithm”</em>.</strong> It moves all the older memory to the beginning of the heap so that a new memory allocation are done in continuous chunk at the end of the Heap, which makes it faster to allocate new chunks of memory to the Heap.</p><blockquote>Recommended to be used : Where multiple JVMs run over same machine[i.e. when JVM will run GC it will use only one processor to minimize the interference of the remaining JVMs]. When application runs on client style machines.</blockquote><p><strong><em>Parallel Garbage Collector: </em></strong>It is a default Garbage collector of JVM. It internally uses<strong> <em>“Mark Compact Collection Algorithm”</em>.</strong> It uses multiple threads to execute Minor GC thereby reducing serial execution time. Its similar to the Serial Garbage Collector except for that it uses multiple threads for Minor GC[parallel execution in Minor GC] and single thread for Major GC[serial execution for Major GC]</p><blockquote>Recommended to be used: When an application can afford low pause time or application running on host with multiple CPUs.</blockquote><p><strong><em>Concurrent Mark Sweep Garbage Collector: </em></strong>It uses multiple threads to scan the Heap memory. CMS Garbage collector holds the application threads in two scenarios : while marking the referenced objects in tenured generation space or if there is a change in heap memory in parallel while doing the GC. It minimizes the pause time by doing most of the GC work concurrently with the application threads.It internally uses<strong> <em>“Mark and Sweep Algorithm”</em>.</strong> In Major GC, the CMS Garbage collector pauses all the application threads for a brief period of the time at the beginning of the collection and towards the middle of the collection; second pause being longer than the first one.</p><blockquote>Recommended to be used: when application requires low Garbage Collection pause-time, when an application can afford to share processor resources with GC while application is still running and when an application has relatively a larger set of tenured generation and runs over a machine with 200 or more processors.</blockquote><p><strong><em>G1 Garbage Collector:</em></strong> It was primarily introduced in Java 7 to be a substitution for CMS Garbage Collector. G1 Garbage Collector is parallel[concurrent]and incremental compacting low pause-time Garbage collection. It offers customization so that user can give their preferred pause-times. It focuses on limiting the pause-time and maximizing the throughput. Its distinctive feature is that it divides the heap memory into many[unused, humongous, Eden, survivor,old generation] fixed sized regions[around 2000 regions whose size varies from 1- 32 MB] , there by giving greater flexibility in memory usage. It uses “<strong><em>Snapshot At The Beginning Algorithm”</em></strong>, which is faster than CMS.</p><blockquote>Recommended to be used: for large heap memory areas, when rate of object allocation or promotion varies significantly, when long GC [&gt;0.5 to 1 sec] is acceptable.</blockquote><p><strong><em>Some other GC types are:</em></strong></p><p><strong><em>Incremental low pause Garbage Collector, ParNew Garbage Collector, PS Scavenger and PS MarkSweep Garbage Collector</em></strong></p><p><strong><em>All you should know about the Automatic Garbage Collection: </em></strong>AGC is the process of identifying and deleting the unused objects in the heap memory. The process is split into <strong>marking and deleting</strong> of the unused objects. The AGC firstly marks which part of memory is in use and which is not. Before marking the objects are referred in blue coloration[stating they are in alive state]and after being marked they are in orange coloration[stating they are not in use anymore]. Once marking of all the objects are done, the process of deletion starts. The deletion process is further split into<strong> normal deletion and compact deletion</strong>. In normal deletion, the unreferenced objects are removed leaving the referenced objects and pointers to the freespace. The memory allocator holds the address of these pointers to freespace, so that new objects can be filled in here. The compact deletion improves the performance by removing all the unreferenced objects and moving all the referenced objects together so that new memory allocation becomes easier and faster.</p><blockquote><strong>Ending Note:</strong></blockquote><blockquote><strong>All the Java Object created using “new” keyword is created in Heap memory.</strong></blockquote><blockquote><strong>GC process automatically clears objects that are unused from the Heap in order to reclaim the Heap space; we just need to specify the type of GC at the JVM startup.</strong></blockquote><blockquote><strong>GC calls the finalize() method only once for an object.</strong></blockquote><blockquote><strong>We can force an early Garbage Collection using System.gc(). As System.gc() is called, the daemon threads in the background are given highest priority and perform Garbage Collection. It is the “aging threshold” which decides the moving of referenced objects from one generation to the other!</strong></blockquote><p>That is it on this article from my end. Hope it was of some help to you in better understanding what a Heap Memory is and how Garbage collection functions.</p><p>Until next time!</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dca0c5b7411" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/general-article-on-how-a-heap-memory-works-and-role-of-a-garbage-collector-in-it-9dca0c5b7411">General article on how a Heap memory works and role of a Garbage Collector in it!</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JVM Architecture:]]></title>
            <link>https://medium.com/javamadetranquil/jvm-architecture-29f6ab33e208?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/29f6ab33e208</guid>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[concept]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Tue, 06 Oct 2020 17:41:44 GMT</pubDate>
            <atom:updated>2023-02-07T22:20:02.798Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*BcUExYotX7jmKs_fUiwMHA.jpeg" /><figcaption>JVM- Architecture [pic credit: google]</figcaption></figure><p>Hello Comrades,</p><p>Today we are looking forward to a brief understanding on how the JVM architecture is made and what are the components it holds within. Here we will be understanding the working or say role of all the components. So, let us begin with it!</p><p>The JVM architecture is divided into three major portions:</p><ul><li>Class Loader sub sytems</li><li>Runtime Data Area</li><li>Execution Engine</li></ul><p><strong>The Class Loader Subsystem:</strong></p><p>The Java Class Loader loads the classes into the JVM. All virtual machines include one Class Loader which is embedded into the virtual machines.This embedded loader is called the <strong>primordial class loader. </strong>This class by default implements the default implementations of loadClass().</p><p>A class is loaded in two scenarios , when a<strong> new bytecode is executed</strong> and when a <strong>bytecodes makes static references to a class</strong>[ we shall discuss this in detail in further topics].</p><p>Java’s dynamic class loading functionality is handled by this Class Loader Subsystem. It basically loads, links and initializes the class files at runtime.</p><p>The Java Class Loader is based on three principles :</p><ul><li><strong>Delegation principle</strong>: This principle forwards a request for the class loading to its parent class loader. It only loads the class if the parent does not find or load a class.</li><li><strong>Visibility principle</strong>: This principle gives visibility only to the child class loader to see all the classes are loaded by a parent class, but not vice a versa.</li><li><strong>Uniqueness principle</strong>: This principle allows any class to be loaded only once. It is briefly achievable by the Delegation principle, it ensures that no class which are loaded by the parent class is reloaded by the child class.</li></ul><p><strong>The types of Class Loader :</strong> The Class Loaders are of following types based on from which path has the class been loaded.</p><ul><li><strong>Bootstrap Class Loader</strong>: It is the parent of all the Class Loaders. It loads the class files from the Core classes. It is also called as Primordial Class Loader. It loads the class from rt.jar file i.e. jre/lib/rt.jar</li><li><strong>Extensions Class Loader</strong>: It is responsible for loading the classes which are inside the ext folder i.e. jre/lib</li><li><strong>System/Application Class Loader</strong>: It is responsible for loading of classes from application class path.</li></ul><blockquote>The working of JVM is as follows, the System Class Loader delegates load request to the Extension Class Loader, which further delegates request to Bootstrap Class Loader. If the class is detected in the Bootstrap Class Loader, class gets loaded else request again gets transferred to Extension Class Loader; and yet if the class is not found we get a run time exception <strong>java.lang.ClassNotFoundException.</strong></blockquote><p><strong>The Runtime Data Area</strong>:</p><p>The Runtime Data Area is split into Method Area, Heap Area, Stack Area, PC Registers, Native Method Stacks.</p><p><strong>Method Area:</strong> All the class level information i.e. immediate parent name, class name, methods and variables are stored in Method Area. It contains elements which are used in class and in initialization of Objects and Interfaces. Per JVM a single Method Area is allocated. It is a shared resource. It is common across all the threads.</p><p><strong>Heap Area:</strong> Detailed information of all Objects is stored into the Heap Area. Heap Area when accessed by any thread is further divided into Young Generation, Old Generation and PermGen[Permanent Generation]. When an object is created it first visits the Young Generation(Eden space) and when it gets older it further moves into the Old Generation. All the static and instance variables are stored in PermGen[will talk in detail on this in Garbage Collection Topic]. Per JVM a single Heap Area is allocated. It is also a shared resource, common across all threads.</p><p><strong>Stack Area: </strong>JVM creates one runtime stack for every single thread. Every block present into the stack is called an activation record / stack frame which holds all the method calls into it. All the local variable calls are stored into the corresponding frame. After the thread terminates, its stack will be destroyed by the JVM. It is not a shared resource. It throws stackOverFlow error when the stack gets full.</p><p><strong>PC Register:</strong> Stores the address of the current on going execution instruction of a thread. Each thread having specific PC Register. It basically keeps a track on instructions.</p><p><strong>Native Method Stack:</strong> Native methods are those which are written in languages other than Java. Stores the Native method information in to it. Each thread owns its Native method Stack. It is same as the Stack Area , except that it is used for native methods.</p><p><strong>The Execution Engine: </strong>This executes the .class (bytecode) files line by line.It further is classified into : interpreter, Just In Time compiler and Garbage Collector. Interpreter interprets the bytecode and then executes the code. The problem that arises here is , the number of times the any method is called that number of times, the interpreter will be needed. As mentioned in our previous article, JIT compiler is helpful in increasing the efficiency of the interpreter. It compiles the entire bytecode and changes it to the Native code, so that whenever interpreter sees a repeated method calls, JIT compiler provides the directly available Native code, so that re-interpretation is not required; there by increasing the efficiency. JIT compiler is an algorithm, that helps us in compiling as well as interpreting. It performs better for redundant code, but can have an additional runtime overhead, while converting the bytecode to native code. <strong>Profiler </strong>which is the part of JIT compiler is responsible to identify the repeated method calls. JIT compilation is applicable only to repeatedly invoked methods and not for every method. The function of a Garbage Collector is to destroy un-referenced Objects i.e. deallocating any memory which is no longer needed by the running applications.[will have a dedicated article for GC]</p><p><strong>The Native Method Interface : </strong>The Java Native Interface [JNI] is basically helpful in having interactions with the native method libraries, required for execution i.e. it acts as a bridge[Mediator] for method calls and corresponding native libraries.</p><p><strong>The Native Method Libraries:</strong> It is a collection of Native Libraries[c|c++], required by execution engine.</p><p>That is it for today! for any further clarifications or add ons thisc article could have, please reach out to me.</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29f6ab33e208" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/jvm-architecture-29f6ab33e208">JVM Architecture:</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Development Environment- [JDK, JRE,JVM,JIT]]]></title>
            <link>https://medium.com/javamadetranquil/software-development-environment-jdk-jre-jvm-jit-16a63993a13?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/16a63993a13</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[médium]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Thu, 01 Oct 2020 19:35:20 GMT</pubDate>
            <atom:updated>2020-10-01T19:34:32.465Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ggLkhZXhkafwYFgWrLHdFw.jpeg" /><figcaption>The building blocks of Java</figcaption></figure><h3>Software Development Environment- [JDK,JRE,JVM,JIT]</h3><p>Hello Comrades,</p><p>Before we begin with today’s article I would recommend you to take a quick look at the previous article so that we as a team are on the same page of knowledge grasping today!</p><p>Assuming that you have revisited the previous article, lets begin with todays’ topic.</p><p>A Software Development Environment is basically a <strong>collection of hardware </strong>and <strong>software tool</strong> that helps us build any <strong>software systems</strong>. Java is both a programming language as well as a platform.</p><p><strong>JVM:</strong></p><p>Starting with introduction to JVM, Java Virtual Machine is an abstract[virtual] machine that enables us to run any Java program. As mentioned in the previous article, Java is a platform independent language, so when we run our program, the Javac compiler firstly compiles our Java code to bytecode and then JVM translates these bytecodes to native machine code and these machine codes will then be executed on the machines, thus making Java platform independent. JVM is responsible for calling the main() method of any Java code.</p><p>A Java code is written usually for JVM and not for the actual machines. JVM is termed as “virtual” because it is generally implemented in a software on top of a real hardware platform and Operating System. The Java program can be run on any system where a JVM is available. JVM basically acts as the intermediary layer and handles all the Operating System specific details. JVM offers many benefits such as memory management and performance optimizations.</p><p>The JVM performs certain main tasks such as, it loads code, verifies it, executes it and provides a runtime environment.</p><blockquote>Note: Next article will be assigned to a detailed description on JVM Architecture.</blockquote><p><strong>JRE:</strong></p><p>The Java Runtime Environment is a software package that provides us with Java class libraries, along with JVM and other components to run the applications written in Java programming.It is a part of Java Development Kit [JDK]. It is considered as an implementation of JVM. It runs on top of the computer’s Operating System. The JRE is an on-disk system that takes our Java code, combines it with the necessary libraries, and starts the JVM to execute the code.</p><p>JRE includes deployment technologies [Java Plug-in], user interface toolkit[Java 2D], Integration libraries[ JDBC,JNDI], long and util libraries[Java Archive JAR].</p><p><strong>JDK:</strong></p><p>The Java Development Kit provides the foundation on which all the applications are built. It contains variety of tools and utilities that help us develop, package, monitor and deploy the applications. JDK includes javac[Java compiler], rmic[Remote Method Invocation], jar[Java Archive], javadoc[Java Documentation].</p><blockquote><strong>The distinction between the JDK and JRE is that JDK is a package of tools for developing Java -based software where as JRE is a package of tools for running the Java code.</strong></blockquote><p>JDK requires JRE as running the program is a part of developing them. To say it precisely, JDK is an implementation of Java platform specification.</p><p><strong>JIT:</strong></p><p>The Just In Time compiler is a essential part of JRE, responsible for performance optimization. Just In Time Compilation is a way of executing code that includes <strong>compilation during execution of code i.e. at runtime</strong> rather than performing it prior to the execution. It improves the performance of any Java application by compiling platform- neutral Java bytecode to native code at runtime. JIT gets activated when a method is invoked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/0*sSP-urX81Le1Lu5D.gif" /><figcaption>pic credit : google</figcaption></figure><p>That is it from my end on this article , for any further clarifications or rectifications needed, please leave in a comment.</p><p>Peace Out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16a63993a13" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/software-development-environment-jdk-jre-jvm-jit-16a63993a13">Software Development Environment- [JDK, JRE,JVM,JIT]</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[…Why Java !]]></title>
            <link>https://medium.com/javamadetranquil/why-java-a9451f7fe03a?source=rss----6f7e51fba52---4</link>
            <guid isPermaLink="false">https://medium.com/p/a9451f7fe03a</guid>
            <category><![CDATA[oops-concepts]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Rupam Jha]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 18:00:51 GMT</pubDate>
            <atom:updated>2020-09-27T18:33:43.317Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23rR1XUAhrZ1AmaKmgbwXw.jpeg" /><figcaption>lets keep our knowledge’s root stronger!</figcaption></figure><p><strong>…Why Java !</strong></p><p>Hello Comrades,</p><p>In the coming decades we will be teaching programming just like reading and writing… and wondering why we didn&#39;t do it sooner! But as the saying goes “Its never too late to be what you might have been!”</p><p>…to begin with ! Just make sure you, as an individual are aware of one fact, for why should you understand any programming language? The mindset you create today, while starting your journey into the Computer Programming is very important, as it is going to be the driving force towards your goal of excelling in Computer Programming!</p><p>So let us analyse and understand why are we boarding onto this journey of learning any programming language, take a pause from this article and analyse why you want to be one among the million aspirants who wish to excel in Programming… It can be any reason… be it that your interested in creating an application that helps your parent keep a track record of their Sugar levels every month or be it a GUI fascinating your little siblings help learn mathematics or be just a meme generator as per the weather forecast in your location, you name it… and its all achievable…. This goal, passion and determination is what will keep you driven in this never ending journey of learning programming!</p><p>So now that you know what it is that you want to create in this programming world, lets begin to dive deep into why we choose Java over rest of the languages !</p><p>This Core Java tutorial is designed for beginners as well as intermittent level programmers. It will help you understand and acquire a good knowledge and clarity on every concept of Java as a programming language.</p><p>Commencing with the facts to be known about Java, lets understand some characteristics that make Java an user friendly language.</p><ul><li>As many a times you would have come across the terminology of Java being an Object Oriented Programming language[OOPs]. Well, what it actually means is that Java as a programming language is organized around <strong>objects </strong>and <strong>data </strong>rather than <strong>functions </strong>and <strong>logic</strong>. Making it further more simpler for you folks, OOP certainly is inclined towards the object that the developers would manipulate rather than the logic needed to manipulate them. It serves various benefits such as re-usability of Code, scalability and efficiency.</li><li>Adding to your general awareness, <a href="https://en.wikipedia.org/wiki/Simula"><strong>Simula </strong></a>was the first ever Object Oriented Programming language this Programming world could witness. Although today we have many Object Oriented Programming languages in market such as C++, Java, JavaScript, Python, Ruby, Scala, PHP; Java certainly better in its own ways.</li><li>Java is a <strong>Platform independent</strong> programming language, i.e. you can run the code on all the available Operating Systems with respect to its development and compilations done. To elaborate on this, when we install a Java Development Kit [<strong>JDK</strong>] into our Systems, implicitly Java Virtual Machine [<strong>JVM</strong>] is also installed. For every Operating System we have a separate JVM which is capable to read the <strong>bytecodes </strong>[.class files]. Now when we compile our code, a bytecode is generated by our javac compiler, which is further processed to JVM. Every Operating System has its own JVM , thereby <strong>making JVM platform dependent.</strong> Java then recognizes the platform it is running the code on and converts these bytecodes to the native machine code; making a Java program run on any platform.</li></ul><p>SourceCode →Compiler →ByteCode → JVM →NativeMachineCode</p><ul><li>Java is <strong>simple</strong>, <strong>robust</strong>, <strong>secure </strong>and <strong>Architecture neutral</strong>, meaning that Java uses a strong memory management[will cover in detail in upcoming post]. Unlike C++ , Java does not support pointers, hence avoiding the security problems. Java becomes an architecture neutral language by not having any implementation dependent features, for eg. the size of the primitive data types remains fixed, Unlike C where int data type occupies 2 bytes of memory for a 32-bit architecture and 4 bytes in a 64-bit architecture.</li><li>Java supports multi threading , i.e. we can perform many tasks simultaneously, thus allowing us to develop interactive applications.</li><li>Java with the use of Just In Time Compiler enables a high performance. It is considered to be more dynamic than C/ C++ as it can carry out an extensive amount of run-time information.</li></ul><p>That’s it on this article. Lets tighten our shoelaces to be on board all set to be the best versions of programmers we can be!</p><p>Peace out!</p><p><a href="https://medium.com/u/ef52184cb151">Rupam Pawan Jha</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9451f7fe03a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javamadetranquil/why-java-a9451f7fe03a">…Why Java !</a> was originally published in <a href="https://medium.com/javamadetranquil">JavaMadeTranquil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>