<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hariharan S J</title>
    <description>The latest articles on DEV Community by Hariharan S J (@hariharan_sj_2003).</description>
    <link>https://dev.to/hariharan_sj_2003</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3695479%2Fbaea2418-be77-4c08-b2c8-6ab0e5325e7a.png</url>
      <title>DEV Community: Hariharan S J</title>
      <link>https://dev.to/hariharan_sj_2003</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hariharan_sj_2003"/>
    <language>en</language>
    <item>
      <title>The Meetup Story</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Mon, 15 Jun 2026 10:28:44 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/the-meetup-story-2pb0</link>
      <guid>https://dev.to/hariharan_sj_2003/the-meetup-story-2pb0</guid>
      <description>&lt;p&gt;Hey Guys&lt;/p&gt;

&lt;p&gt;Today in this blog you are going to see some Curious Topics that What i Have Learned in the Meetup i Attendend&lt;/p&gt;

&lt;p&gt;Before That this sunday i Attended the &lt;strong&gt;ILUGC Meetup&lt;/strong&gt; That meetup was So useful to me as a tech enthusiassist &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;ILUGC&lt;/strong&gt; Community is started their meetup since 1988 so it was got a lot of history about this&lt;/p&gt;

&lt;p&gt;so i learned lot of things on the meetup My Philosophy is if i had learned something new to the technology means i should to some other person so that they should be useful for the content that what i have shared , so i use this blog to share my experice on that particular meetup&lt;/p&gt;

&lt;p&gt;Without Any Further delay lets get Started&lt;/p&gt;

&lt;p&gt;The First talk is about &lt;/p&gt;

&lt;h2&gt;
  
  
  Google's New 2026 Developer Verification Policy – Will It Change the Future of Android?
&lt;/h2&gt;

&lt;p&gt;What's the first thing that comes to mind when we think about Android? Freedom. We can install apps from different sources, download APK files, and even use third-party app stores. However, in 2026, Google introduced a major change called the Developer Verification Policy.&lt;/p&gt;

&lt;p&gt;Under this policy, Android developers must verify their identity with Google before distributing apps. This requirement is not limited to apps published on the Play Store it also applies to developers who distribute APKs through their own websites or other channels.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Problem Is Google Trying to Solve?
&lt;/h2&gt;

&lt;p&gt;The Android ecosystem has faced issues such as malware, scam applications, and fake developer accounts for years.&lt;/p&gt;

&lt;p&gt;In many cases, when a developer account is banned for violating policies, the same person can create a new account and continue distributing harmful apps. Google's goal is to reduce these risks by ensuring that every developer can be identified and held accountable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Does the Policy Require?
&lt;/h2&gt;

&lt;p&gt;Developers may need to provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Legal name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Address&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Email address&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Phone number&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Government-issued identification (in certain cases)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Additional business verification for organization accounts&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This information is used to confirm the identity of the developer before app distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timeline
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Early access began in late 2025.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verification became available to developers in 2026.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enforcement starts in phases during 2026.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wider rollout is expected to continue globally.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages of the Policy
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Improved Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verified developers are easier to track and monitor, making it harder for malicious actors to operate anonymously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Reduced Malware and Scam Apps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By verifying identities, Google can better prevent harmful applications from reaching users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Increased User Trust&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Users will have greater confidence knowing that app developers have gone through an identity verification process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concerns and Criticism
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Will Android Lose Its Openness?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of Android's biggest strengths has always been its open ecosystem.&lt;/p&gt;

&lt;p&gt;Some developers argue that stricter verification requirements could make Android feel more controlled and less open than before.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Impact on Independent Developers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Students, hobby developers, and small open-source contributors may find the verification process more challenging compared to large companies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Sideloading Restrictions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google has stated that sideloading is not being removed. However, apps distributed by unverified developers may face additional security warnings or restrictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Perspective
&lt;/h2&gt;

&lt;p&gt;The intention behind this policy is understandable.&lt;/p&gt;

&lt;p&gt;It aims to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Improve security&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce scams and malware&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increase accountability&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, Google must maintain a balance between security and openness.&lt;/p&gt;

&lt;p&gt;Security is important.&lt;br&gt;
Freedom is important too.&lt;/p&gt;

&lt;p&gt;Android became successful not only because it was secure, but also because it gave users and developers the freedom to innovate.&lt;/p&gt;

&lt;p&gt;The real challenge is finding the right balance between these two values.&lt;/p&gt;

&lt;p&gt;After this they all requested to give a shor intro about ourself so i also gave a short intro about this &lt;/p&gt;

&lt;p&gt;in between the topic a heated argument is going on between linux vs windows which os is the best to use each person shared their own point of view to say which one is the best &lt;/p&gt;

&lt;p&gt;personally if you ask me linux is the best for developers because if i want to write a normal print statement in python i want to download a IDE to run it or or i want to run it on any by using the online google compiler by using windows &lt;/p&gt;

&lt;p&gt;but by using linux python is inbuildtly there is linux &lt;/p&gt;

&lt;p&gt;The Second Talk is about the Opensource Testing Tool Called &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Playwright&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;he also told like why Playwright is best than Selinium he also give a lot of technical inputs about the playwright tool &lt;/p&gt;

&lt;h2&gt;
  
  
  My Final Thoughts
&lt;/h2&gt;

&lt;p&gt;It was an Eye Opening session for me because from there on my curiousity level increses like whats is going on the technical world how we are going about in the future like that thoughts are think myself&lt;/p&gt;

&lt;p&gt;so thats all gyus you can also attend the ILUGC Monthly Meetup they conduct every month of second saturday&lt;/p&gt;

&lt;p&gt;Go to the Official Site of ILUGC , go to the contact page in there Subscribe to the ILUGC Mailing List After Subscribing it you get all notification from there which date the meetup is conducted on &lt;/p&gt;

&lt;p&gt;okay gyus see you in the next blog...&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>learning</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Abstraction in Java</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Sat, 13 Jun 2026 05:17:52 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/abstraction-in-java-3n9i</link>
      <guid>https://dev.to/hariharan_sj_2003/abstraction-in-java-3n9i</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Hey guys today in this Blog you are going to learn about one of the OOPS Concepts called Abstraction&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Note&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Before studying or Practising this topic please do Study the OOPS concepts of class,object,Polymorphism,Inheritance and Endcapsulation because The OOPS concepts are deeply intertwined, and understanding one concept helps in understanding the others without studying those topics this topics would be much much difficult to understand so please do ensure to study those topics before comming into this topic &lt;/p&gt;

&lt;p&gt;without any further delay let's get started&lt;/p&gt;

&lt;h2&gt;
  
  
  2.What is mean by Abstraction
&lt;/h2&gt;

&lt;p&gt;first we will discuss this term non technically &lt;/p&gt;

&lt;p&gt;Abstract means a 5 to 10 lines Which will discribe the whole Paragraph&lt;/p&gt;

&lt;p&gt;for ex : take your college final year abstract in that how's the project working is only is there in abstract the functionalities or the parts of behaviour is not mention in the abstract or in simple words it can be called as a Synopsis&lt;/p&gt;

&lt;p&gt;Like that&lt;/p&gt;

&lt;p&gt;Abstraction in Java is the process of hiding internal implementation details and showing only essential functionality to the user. It focuses on what an object does rather than how it does it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It hides the complex details and shows only essential features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstract classes may have methods without implementation and must be implemented by subclasses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By abstracting functionality, changes in the implementation do not affect the code that depends on the abstraction.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(&lt;a href="https://www.geeksforgeeks.org/java/abstraction-in-java-2/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/java/abstraction-in-java-2/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-Life Example of Abstraction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovayv5xxvr62vkxuq580.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovayv5xxvr62vkxuq580.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine you are the guy who is Standing in Front of an ATM Machine Like this in the photo , you enter the card in the machine and you click the withdraw option in Machine , and put your Personal Identification Number Which is Shortly Called as PIN Number &lt;/p&gt;

&lt;p&gt;You Wait for few seconds after the machine dispence the cash you take the cash and go for your work&lt;/p&gt;

&lt;p&gt;but have you ever wondered like what is the internal process going on inside the machine &lt;/p&gt;

&lt;p&gt;yeahh your guessing is right it also follows abstraction because u can only see the screen and buttons of the atm machine through your eyes but you cannot see whats going on inside process&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Why is Abstraction used in Java?
&lt;/h2&gt;

&lt;p&gt;Abstraction is used to hide implementation details and show only the essential features of an object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simple Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Take a car , in car everything in an object like the wiper , tire, Seat belt like that so for a driver which object should important is &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Steering wheel&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Acclerator&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Brake&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clutch&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gear&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Driver don't need to know how the engine, gearbox, or fuel injection system works internally.&lt;/p&gt;

&lt;p&gt;This is abstraction — exposing what to do while hiding how it is done.&lt;/p&gt;

&lt;p&gt;Okay now lets see some example Code after seeing the code you can even more connect with these topic called Abstraction&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Indians&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;haveBreakfast&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;applyRationCard&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Ration card"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;applyDrivingLisence&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Driving lisence"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Tamils&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Indians&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Tamils&lt;/span&gt; &lt;span class="n"&gt;thamizhan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Tamils&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="n"&gt;thamizhan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;applyRationCard&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;thamizhan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;applyDrivingLisence&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;thamizhan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;haveBreakfast&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;haveBreakfast&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Idly , Dosa"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  India is a country where Diverse culture is there that's why India is popularly called as "Unity in Diversity"
&lt;/h2&gt;

&lt;p&gt;this code is related to that because in Indians.java i have a method called have method called&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;haveBreakfast&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;haveBreakfast Method cannot be defined because in south india which Tami nadu , Kerala , Andhra Pradesh and Karnataka eat Different foods whereas north india which is Maharashtra , Uttar Pradesh , Bihar like that they eat different foods for their Breakfast&lt;/p&gt;

&lt;p&gt;so the method breakfast is undefined &lt;/p&gt;

&lt;h2&gt;
  
  
  Rule 1 in abstraction
&lt;/h2&gt;

&lt;p&gt;even if one method is Abstract in one class then the Entire Class Should be Abstract&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule 2 Object Should not Be created in the Abstract Class
&lt;/h2&gt;

&lt;p&gt;When you are creating Object in the Abstract Class it will show an Error like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abstract class cannot be instantiated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the help of Inheritance you can create a child class for your parent class and create object for your child and call the non static methods from your child class of your child object&lt;/p&gt;

&lt;p&gt;so when you execute this program the output of the program will be&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1g71027d3w7a9aiofhk9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1g71027d3w7a9aiofhk9.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Java provides two ways to implement abstraction, which are listed below:&lt;/p&gt;

&lt;p&gt;1.)Abstract Classes (Partial Abstraction)&lt;/p&gt;

&lt;p&gt;2.)Interface (provides abstraction for behavior, may contain default or static methods)  &lt;strong&gt;To Be Discussed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Okay guys i hope somewhat you understand About this Topic if you having Any Doubts Drop it down in the Comment Section &lt;/p&gt;

&lt;h2&gt;
  
  
  My Final Thoughts About This Topic
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/XQPy88-E2zo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You may Watched this movie or you may Heard about this movie called Inception so Basically the movie is all about dreams vs reality esspecially the climax is scene is an ultimate twist Because the Hero of the movie Cob spins of his totem if the totem automatically stops menas the hero is in reality if it is not stopped or else if it is continuously spins means the hero will be in dream &lt;/p&gt;

&lt;p&gt;the mad man director christopher nolan takes the scene and in the climax hero spins his totem and go to his child but the biggest question here is wheather the totem is stopped or not &lt;/p&gt;

&lt;p&gt;christopher nolan sends it to the audiance perspective let audiance decide wheather the totem is stopped or not &lt;/p&gt;

&lt;p&gt;but accoding to technically it is undefined because the creator of the film itself designed like that only &lt;/p&gt;

&lt;p&gt;Like wise the same way The Abstraction Applies to the Undefined Methods&lt;/p&gt;

&lt;p&gt;See you in my next blog guys ...&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>learning</category>
    </item>
    <item>
      <title>The Hidden Beauty of Numbers: Solving Perfect Numbers, Factorials, and More with Python</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Sat, 06 Jun 2026 07:25:42 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/the-hidden-beauty-of-numbers-solving-perfect-numbers-factorials-and-more-with-python-4j3k</link>
      <guid>https://dev.to/hariharan_sj_2003/the-hidden-beauty-of-numbers-solving-perfect-numbers-factorials-and-more-with-python-4j3k</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Did you know that some numbers are considered so special that mathematicians have been studying them for thousands of years?&lt;/p&gt;

&lt;p&gt;Take the number 28, for example. At first glance, it looks like any ordinary number. But surprisingly, it belongs to a rare category known as &lt;strong&gt;Perfect Numbers&lt;/strong&gt;. Similarly, concepts like factorials and number series play a crucial role in mathematics, probability, and computer science.&lt;/p&gt;

&lt;p&gt;As programmers, understanding how to solve these problems not only improves our coding skills but also strengthens our logical thinking. One of the best tools for solving such problems in Python is the &lt;strong&gt;while loop&lt;/strong&gt;, a simple yet powerful looping construct that allows us to repeat tasks efficiently.&lt;/p&gt;

&lt;p&gt;In this article, we'll build and understand four practical Python programs using while loops. By the end, you'll have a better understanding of Perfect Numbers, Factorials, Number Patterns, and Summation Techniques while also improving your Python programming skills.&lt;/p&gt;

&lt;p&gt;Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Perfect Number Program
&lt;/h2&gt;

&lt;p&gt;A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding itself. For instance, 28 is a perfect number because the sum of its divisors (1, 2, 4, 7, and 14) is 28.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Perfect numbers are also known as "Complete Numbers" in number theory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some of the first perfect numbers are 6, 28, 496, and 8128&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As of 2025, a total of 52 perfect numbers have been discovered.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjk46j9042ygrlzms42m6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjk46j9042ygrlzms42m6.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other Examples&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;28&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;496&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;8128&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;33550336 up to infinity.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The latest Perfect Number was discovered in 2024 and has 82,048,64 digits.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.Why are Perfect Numbers Important?
&lt;/h2&gt;

&lt;p&gt;Perfect Numbers have fascinated mathematicians for thousands of years and are an important topic in Number Theory. They help researchers study the relationships between numbers and understand mathematical patterns.&lt;/p&gt;

&lt;p&gt;For programmers, perfect number problems are useful because they teach important concepts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Loops&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conditional statements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Divisor calculation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modulus operator (%)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Problem-solving skills&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Perfect number questions are also common in coding interviews, programming assignments, and competitive programming contests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;

&lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;divisor&lt;/span&gt;
    &lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Perfect Number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Not a Perfect Number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌───────┐
 │ Start │
 └───┬───┘
     │
     ▼
Initialize
no, divisor, sum
     │
     ▼
divisor &amp;lt; no ?
     │
 ┌───┴───┐
 │  Yes  │
 └───┬───┘
     │
     ▼
no % divisor == 0 ?
     │
 ┌───┴────┐
 │  Yes   │
 └───┬────┘
     │
     ▼
sum = sum + divisor
     │
     ▼
divisor++
     │
     └──────────┐
                │
                ▼
        divisor &amp;lt; no ?
                │
                ▼
       Loop Continues

After Loop

sum == no ?
     │
 ┌───┴───┐
 │       │
 ▼       ▼
Perfect  Not Perfect
Number   Number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Perfect Number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How the Program Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The program checks every number from 1 up to the given number. Whenever a number divides the given number completely, it is considered a divisor and added to the sum. Finally, if the sum of all divisors equals the original number, the program prints "Perfect Number".&lt;/p&gt;

&lt;h2&gt;
  
  
  4.Odd and Even Number Pattern in a Single Loop
&lt;/h2&gt;

&lt;p&gt;Sometimes a problem can be solved in multiple ways. The following program generates odd numbers first and then even numbers using a single loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌───────┐
 │ Start │
 └───┬───┘
     │
     ▼
 no = 1
     │
     ▼
 no &amp;lt;= 10 ?
     │
 ┌───┴───┐
 │  Yes  │
 └───┬───┘
     │
     ▼
 no &amp;lt;= 5 ?
     │
 ┌───┴─────┐
 │         │
 ▼         ▼
Print      Print
Odd        Even
Formula    Formula
     │
     ▼
 no++
     │
     └─────Loop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
3
5
7
9
2
4
6
8
10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How the Program Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For the first five iterations, the formula (no * 2) - 1 generates odd numbers.&lt;/p&gt;

&lt;p&gt;For the remaining iterations, the formula (no - 5) * 2 generates even numbers.&lt;/p&gt;

&lt;p&gt;This approach demonstrates how mathematical expressions and conditions can be combined inside a single loop to produce a specific pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.Factorial of a Number
&lt;/h2&gt;

&lt;p&gt;Factorial is one of the most commonly used mathematical operations in programming.&lt;/p&gt;

&lt;p&gt;The factorial of a number is the product of all positive integers from 1 to that number.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;5! = 5 × 4 × 3 × 2 × 1 = 120&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is Factorial Used?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Factorials are widely used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Permutations and Combinations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Probability calculations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mathematics&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Algorithm design&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Computer Science research&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Python Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;

&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;fact&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;fact&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fact&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fact&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌───────┐
 │ Start │
 └───┬───┘
     │
     ▼
Initialize
i = 1
fact = 1
     │
     ▼
 i &amp;lt;= no ?
     │
 ┌───┴───┐
 │  Yes  │
 └───┬───┘
     │
     ▼
fact = fact * i
     │
     ▼
i++
     │
     └────Loop

After Loop

     ▼
Print factorial
     │
     ▼
    End
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How the Program Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The variable fact starts with the value 1. The loop multiplies it by every number from 1 to 5. Once the loop finishes, the final result stored in fact becomes 120.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.Sum of First N Numbers
&lt;/h2&gt;

&lt;p&gt;Finding the sum of a sequence is another common programming problem.&lt;/p&gt;

&lt;p&gt;If we want to find the sum of the first 10 numbers:&lt;/p&gt;

&lt;p&gt;1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10&lt;/p&gt;

&lt;p&gt;The result is:&lt;/p&gt;

&lt;p&gt;55&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Flowchart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌───────┐
 │ Start │
 └───┬───┘
     │
     ▼
Initialize
i = 1
sum = 0
     │
     ▼
 i &amp;lt;= no ?
     │
 ┌───┴───┐
 │  Yes  │
 └───┬───┘
     │
     ▼
sum = sum + i
     │
     ▼
i++
     │
     └────Loop

After Loop

     ▼
Print sum
     │
     ▼
    End
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How the Program Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The variable sum starts with 0. During each iteration, the current value of i is added to sum. After all numbers from 1 to 10 are processed, the final value of sum becomes 55.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Applications&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This concept is useful in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Data analysis&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mathematical series calculations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Statistical computations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Algorithm development&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Financial calculations&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7.Conclusion
&lt;/h2&gt;

&lt;p&gt;The while loop is one of the most fundamental tools in Python programming. Although it appears simple, it can be used to solve a wide variety of problems.&lt;/p&gt;

&lt;p&gt;In this article, we explored how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Identify a Perfect Number&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate odd and even number patterns&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Calculate the factorial of a number&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find the sum of the first N numbers&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These programs help beginners strengthen their understanding of loops, conditions, arithmetic operations, and logical thinking. Once you master these concepts, you'll be better prepared to solve more advanced programming challenges in Python.&lt;/p&gt;

&lt;p&gt;Happy Coding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;(&lt;a href="https://www.geeksforgeeks.org/maths/perfect-numbers/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/maths/perfect-numbers/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>learning</category>
    </item>
    <item>
      <title>Behind the Scenes of Java OOP: Constructors to Run Time Polymorphism</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Fri, 05 Jun 2026 11:53:28 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/behind-the-scenes-of-java-oop-constructors-to-run-time-polymorphism-m6m</link>
      <guid>https://dev.to/hariharan_sj_2003/behind-the-scenes-of-java-oop-constructors-to-run-time-polymorphism-m6m</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever wondered what actually happens when you create an object in Java?&lt;br&gt;
Why does the parent constructor execute before the child constructor?&lt;br&gt;
Why can a child class access parent methods, but a parent class cannot directly call a child constructor?&lt;br&gt;
And why is method overriding called Run Time Polymorphism?&lt;/p&gt;

&lt;p&gt;Most beginners learn Java syntax, but very few truly understand what happens behind the scenes when inheritance, constructors, super() keyword, and method overriding work together.&lt;/p&gt;

&lt;p&gt;In this blog, we are going to break down these core OOP concepts in the simplest possible way using real Java examples based on Hotel.java and Vadakkambatti.java.&lt;/p&gt;

&lt;p&gt;By the end of this blog, you will clearly understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How constructors work internally&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How inheritance actually behaves&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why super() is important&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How method overriding works&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why overriding is called Run Time Polymorphism&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Whether return types can be changed during method overriding&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are learning Java or preparing for interviews, these concepts are extremely important because they are frequently asked in technical discussions and coding interviews.&lt;/p&gt;

&lt;p&gt;Let’s dive into the world of Java OOP concepts step by step&lt;/p&gt;
&lt;h2&gt;
  
  
  2.What is a Constructor in Java?
&lt;/h2&gt;

&lt;p&gt;A constructor is a special block in Java that is automatically called when an object is created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Points About Constructors&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Constructor name should be the same as the class name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Constructors do not have a return type&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Constructors are automatically executed during object creation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Constructors are mainly used to initialize object values&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;foodName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Hotel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;foodName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;

        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;foodName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;foodName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foodName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;

        &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="n"&gt;item1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Chicken Biriyani"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;item1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;display&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chicken Biriyani
250
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the constructor initializes the values using this.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.Understanding Inheritance in Java
&lt;/h2&gt;

&lt;p&gt;A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).&lt;/p&gt;

&lt;p&gt;Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the absence of any other explicit superclass, every class is implicitly a subclass of Object.&lt;/p&gt;

&lt;p&gt;Classes can be derived from classes that are derived from classes that are derived from classes, and so on, and ultimately derived from the topmost class, Object. Such a class is said to be descended from all the classes in the inheritance chain stretching back to Object.&lt;/p&gt;

&lt;p&gt;The idea of inheritance is simple but powerful: When you want to create a new class and there is already a class that includes some of the code that you want, you can derive your new class from the existing class. In doing this, you can reuse the fields and methods of the existing class without having to write (and debug!) them yourself.&lt;/p&gt;

&lt;p&gt;A subclass inherits all the members (fields, methods, and nested classes) from its superclass. Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Child&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Parent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Parent class → Super class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Child class → Sub class&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4.Understanding super Keyword in Java
&lt;/h2&gt;

&lt;p&gt;The super keyword in Java is used to refer to the immediate parent class object in an inheritance hierarchy. It allows a subclass to explicitly access parent class members when they are hidden or overridden. This keyword helps maintain clarity and control while working with inheritance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Used to call parent class constructors using super().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Helps access parent class methods and variables when overridden or hidden.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensures proper inheritance behavior and code reusability.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hotel.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;Hotel&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Parent Constructor"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Vadakkambatti.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Child Constructor"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;

        &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Parent Constructor
Child Constructor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What Happens Here?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the child object is created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java automatically calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This super() calls the parent class constructor first.&lt;/p&gt;

&lt;p&gt;So the execution order becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Parent constructor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Child constructor&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important Rules About super Keyword&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;super() must be the first statement inside the child constructor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is used to call the parent constructor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If super() is not written, Java automatically inserts it&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5.Can Parent Class Call Child Constructor?
&lt;/h2&gt;

&lt;p&gt;This is one of the most confusing questions for beginners.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer: No&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A parent class cannot directly call a child class constructor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrong Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;Hotel&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Error&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces a compile-time error like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cannot find symbol
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reason&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Constructors cannot be called like normal methods.&lt;/p&gt;

&lt;p&gt;Correct way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Constructors only execute during object creation.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.What is Method Overriding?
&lt;/h2&gt;

&lt;p&gt;Method overriding means redefining a parent class method inside the child class with the same method name and same parameters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When a method in a subclass has the same name, same parameters or signature, and same return type(or sub-type) as a method in its super-class, then the method in the subclass is said to override the method in the super-class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method overriding is one of the way by which java achieve Run Time Polymorphism.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage of Java Method Overriding&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Method overriding is used to provide the specific implementation of a method which is already provided by its superclass.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method overriding is used for runtime polymorphism.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hotel.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;SpecialFood&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Chicken Biriyani"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Vadakkambatti.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;SpecialFood&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Grill Chicken"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;

        &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;SpecialFood&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Grill Chicken
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the child class overrides the parent method and provides its own implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  7.Why Method Overriding is Called Run Time Polymorphism?
&lt;/h2&gt;

&lt;p&gt;In method overriding, Java decides which method to execute during run time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;SpecialFood&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though the reference type is Hotel, the object type is Vadakkambatti.&lt;/p&gt;

&lt;p&gt;So Java checks the actual object during execution and calls the child method.&lt;/p&gt;

&lt;p&gt;This decision happens at run time, so method overriding is called:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run Time Polymorphism
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Can We Change Return Type in Method Overriding?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer: Yes and No&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return type can be changed only in certain situations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Same Return Type&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here both methods return int, so overriding is valid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Covariant Return Type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A child class return type can replace the parent class return type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Biriyani&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="nf"&gt;SpecialFood&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Food&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;Biriyani&lt;/span&gt; &lt;span class="nf"&gt;SpecialFood&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Biriyani&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Covariant Return Type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Completely Different Return Type&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vadakkambatti&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hotel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt; &lt;span class="c1"&gt;// Error&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"Two Hundred"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces a compile-time error because int and String are unrelated return types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Rule for Method Overriding&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The method must have the same name as in the parent class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The method must have the same parameter as in the parent class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compatible return type&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inheritance relationship&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8.Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Understanding constructors, inheritance, super keyword, method overriding, and return types is essential for mastering Java OOP concepts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Constructors initialize objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inheritance helps reuse code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;super() calls parent constructors&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parent constructors can be called by child classes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Child constructors cannot be directly called by parent classes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method overriding enables run time polymorphism&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Return type can be changed only if it is compatible&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once these basics become clear, advanced Java concepts become much easier to understand.&lt;/p&gt;

&lt;p&gt;Happy Coding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;(&lt;a href="https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html" rel="noopener noreferrer"&gt;https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://www.geeksforgeeks.org/java/super-keyword/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/java/super-keyword/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://java-iitd.vlabs.ac.in/exp/method-overriding/theory.html" rel="noopener noreferrer"&gt;https://java-iitd.vlabs.ac.in/exp/method-overriding/theory.html&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>learning</category>
    </item>
    <item>
      <title>Python While Loop Practice: Multiples, Divisors, Count of Divisors &amp; Prime Numbers</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Thu, 04 Jun 2026 14:23:12 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/python-while-loop-practice-multiples-divisors-count-of-divisors-prime-numbers-2lm5</link>
      <guid>https://dev.to/hariharan_sj_2003/python-while-loop-practice-multiples-divisors-count-of-divisors-prime-numbers-2lm5</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;What do multiples of numbers, divisors, and prime numbers have in common?&lt;/p&gt;

&lt;p&gt;At first glance, they may seem like simple math concepts we learned in school. But behind the scenes, these are some of the most common problems programmers solve using loops and conditions.&lt;/p&gt;

&lt;p&gt;Imagine asking a computer questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Which numbers between 1 and 100 are divisible by both 3 and 5?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How can I find all divisors of a number?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How many divisors does a number have?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Is a given number prime or not?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer to all these questions starts with one fundamental programming concept: the while loop.&lt;/p&gt;

&lt;p&gt;In this article, we'll use a series of simple Python programs to explore how while loops work and how they can be used to solve real mathematical problems. Whether you're a beginner learning Python or someone looking to strengthen your problem-solving skills, these examples will help you understand the power of loops in a practical way.&lt;/p&gt;

&lt;p&gt;Let's dive in and see how a few lines of Python code can solve some interesting number-based challenges.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Finding Numbers Divisible by Both 3 and 5
&lt;/h2&gt;

&lt;p&gt;Let's start with a simple problem.&lt;/p&gt;

&lt;p&gt;We need to print all numbers between 1 and 100 that are divisible by both 3 and 5.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;false&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The loop starts from 1 and continues until 100.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;% is the modulus operator that returns the remainder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a number leaves a remainder of 0 when divided by both 3 and 5, it gets printed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Such numbers are multiples of 15.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15
30
45
60
75
90
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3.Finding Numbers Divisible by Either 3 or 5
&lt;/h2&gt;

&lt;p&gt;Now let's print numbers that are divisible by 3 or 5.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;false&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Here we use the or operator instead of and.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a number is divisible by either 3 or 5, it will be printed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3
5
6
9
10
12
15
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Finding the Divisors of a Number
&lt;/h2&gt;

&lt;p&gt;A divisor is a number that divides another number completely without leaving a remainder.&lt;/p&gt;

&lt;p&gt;Let's find all divisors of 20.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Start checking from 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If 20 is divisible by the current value of i, print it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Continue until i reaches 20.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
2
4
5
10
20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Counting the Number of Divisors
&lt;/h2&gt;

&lt;p&gt;Instead of just printing divisors, we can count them as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;
&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Count =&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Every time a divisor is found, increase count by 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the loop finishes, print the total count.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
2
3
4
5
6
12
Count = 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since 12 has six divisors, the count is 6.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.Checking Whether a Number is Prime
&lt;/h2&gt;

&lt;p&gt;A prime number has exactly two divisors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Number Itself&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's check whether 13 is prime.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;
&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Prime Number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Not a Prime Number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Count the total number of divisors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the count is exactly 2, the number is prime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Otherwise, it is not prime.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prime Number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because 13 is divisible only by 1 and 13.&lt;/p&gt;

&lt;h2&gt;
  
  
  7.Why These Programs Matter
&lt;/h2&gt;

&lt;p&gt;These examples may look simple, but they introduce several important programming concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;While loops&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conditional statements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modulus operator (%)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Counting Logic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Number theory fundamentals&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding these concepts will help you solve more advanced coding problems in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  8.Final Takeaway
&lt;/h2&gt;

&lt;p&gt;The while loop is one of the most powerful tools for beginners learning Python. By combining loops with conditions, you can solve a variety of mathematical problems such as finding multiples, identifying divisors, counting factors, and checking prime numbers.&lt;/p&gt;

&lt;p&gt;Master these basics, and you'll build a strong foundation for tackling more complex programming challenges.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>backend</category>
    </item>
    <item>
      <title>What Really Happens When You Create an Object in Java? Understanding Constructors and Packages</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Wed, 03 Jun 2026 13:21:54 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/what-really-happens-when-you-create-an-object-in-java-understanding-constructors-and-packages-38ae</link>
      <guid>https://dev.to/hariharan_sj_2003/what-really-happens-when-you-create-an-object-in-java-understanding-constructors-and-packages-38ae</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever created an object in Java and wondered what happens behind the scenes the moment that object comes to life?&lt;/p&gt;

&lt;p&gt;When you write something as simple as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java doesn't just magically create an object. It first invokes a special mechanism called a constructor, which prepares the object and gets it ready for use. Whether you're assigning default values or passing custom data during object creation, constructors play a crucial role in every Java application.&lt;/p&gt;

&lt;p&gt;But creating objects is only part of the story.&lt;/p&gt;

&lt;p&gt;As applications grow from a few classes to hundreds or even thousands, managing code becomes a challenge. Imagine trying to find a single class in a project where every file is stored in the same folder. That's where packages come in. Packages help developers organize code, avoid naming conflicts, and build scalable applications that are easier to maintain.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore the different types of constructors in Java, understand how they work, and learn how packages help structure real-world Java projects. By the end, you'll have a solid understanding of two fundamental concepts that every Java developer uses daily.&lt;/p&gt;

&lt;p&gt;In my previous blog i had discussed what is constructor? , why constructor is needed in this blog we are going to discuss about the Types of Constructor and Packages&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Types of Constructors in Java
&lt;/h2&gt;

&lt;p&gt;Java mainly provides three types of constructors:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Default Constructor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No-Argument Constructor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parameterized Constructor&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Default Constructor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A default constructor is automatically provided by the Java compiler when no constructor is explicitly written.&lt;/p&gt;

&lt;p&gt;If we do not create any constructor, the Java compiler automatically creates a no-arg constructor during the execution of the program.&lt;/p&gt;

&lt;p&gt;This constructor is called the default constructor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since no constructor was defined, Java automatically generated a default constructor and assigned default values to instance variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. No-Argument Constructor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A no-argument constructor is created by the programmer and does not accept any parameters&lt;/p&gt;

&lt;p&gt;Similar to methods, a Java constructor may or may not have any parameters (arguments).&lt;/p&gt;

&lt;p&gt;If a constructor does not accept any parameters, it is known as a no-argument constructor. For example,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hari"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;101
Hari
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Use It?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A no-argument constructor allows us to initialize objects with custom default values instead of Java's built-in defaults.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Parameterized Constructor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A parameterized constructor accepts values during object creation.&lt;/p&gt;

&lt;p&gt;A Java constructor can also accept one or more parameters. Such constructors are known as parameterized constructors (constructors with parameters).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hari"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;101
Hari
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Use It?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Parameterized constructors allow each object to have different values during creation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hari"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;103&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"David"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each object stores unique data.&lt;/p&gt;

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

&lt;p&gt;Java allows multiple constructors within the same class as long as their parameter lists are different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No Argument Constructor"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Parameterized Constructor"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hari"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No Argument Constructor
Parameterized Constructor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feature is known as Constructor Overloading.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.What is a Package in Java?
&lt;/h2&gt;

&lt;p&gt;A package is a collection of related classes, interfaces, and sub-packages.&lt;/p&gt;

&lt;p&gt;Think of a package as a folder in your computer.&lt;/p&gt;

&lt;p&gt;Just as folders help organize files, packages help organize Java classes.&lt;/p&gt;

&lt;p&gt;A package in Java is a mechanism to group related classes, interfaces, and sub-packages into a single unit. Packages help organize large applications, avoid naming conflicts, provide access protection, and make code modular and maintainable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Avoiding name conflicts (two classes with the same name can exist in different packages)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Providing access control using public, protected, and default access&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusability: packaged code can be imported and used anywhere&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Encouraging modular programming&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4.Why Do We Need Packages?
&lt;/h2&gt;

&lt;p&gt;Packages provide several advantages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Better Code Organization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Without packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Student.java
Employee.java
Customer.java
Order.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With Packages&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;com.company.student
com.company.employee
com.company.order
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything becomes easier to manage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Prevent Naming Conflicts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Two developers might create classes with the same name.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;student.Student&lt;br&gt;
employee.Student&lt;/p&gt;

&lt;p&gt;Packages help Java identify which class is being used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Access Protection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Packages help control visibility of classes and members using access modifiers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Packages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java provides two types of packages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Built-in Packages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are packages provided by Java itself.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java.lang(TBD)
java.util(TBD)
java.io(TBD)
java.sql(TBD)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. User-Defined Packages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers can create their own packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Package&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;college&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Inside Student Class"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using the Package&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;college.Student&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Main&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;display&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Package Naming Convention&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java package names usually follow reverse domain naming.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;com.google
com.microsoft
com.amazon
org.apache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps avoid naming conflicts in large applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Constructors and packages may seem like small Java concepts at first, but they play a huge role in real-world application development.&lt;/p&gt;

&lt;p&gt;Constructors ensure that objects are properly initialized when created, while packages help organize code into meaningful structures.&lt;/p&gt;

&lt;p&gt;As your Java projects become larger and more complex, understanding these two concepts will help you write cleaner, more maintainable, and professional-quality code.&lt;/p&gt;

&lt;p&gt;Master constructors to control object creation. Master packages to control project organization. Together, they form a strong foundation for becoming an effective Java developer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://www.geeksforgeeks.org/java/packages-in-java/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/java/packages-in-java/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://www.programiz.com/java-programming/constructors" rel="noopener noreferrer"&gt;https://www.programiz.com/java-programming/constructors&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>learning</category>
    </item>
    <item>
      <title>One While Loop, Seven Patterns, Endless Learning</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Wed, 03 Jun 2026 10:06:11 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/one-while-loop-seven-patterns-endless-learning-2acj</link>
      <guid>https://dev.to/hariharan_sj_2003/one-while-loop-seven-patterns-endless-learning-2acj</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever noticed that most beginners can write a while loop, but struggle when asked to create a simple number pattern?&lt;/p&gt;

&lt;p&gt;The problem isn't the syntax.&lt;/p&gt;

&lt;p&gt;It's understanding how numbers change from one iteration to the next.&lt;/p&gt;

&lt;p&gt;A sequence like 1 2 3 4 5 may look different from 1 3 5 7 9 or 15 12 9 6 3, but behind the scenes, they all follow the same fundamental principle: start with a value, repeat a process, and update that value in a predictable way.&lt;/p&gt;

&lt;p&gt;This is exactly why pattern programs are so popular among programmers. They don't just teach loops—they train your brain to think logically, identify sequences, and understand how a program evolves step by step.&lt;/p&gt;

&lt;p&gt;In this article, we'll use Python's while loop to build a variety of number patterns, from simple counting sequences to reverse and alternating patterns. More importantly, we'll focus on the logic behind each pattern so that by the end, you won't just know how to print these patterns—you'll know how to create your own.&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Why Learn Patterns?
&lt;/h2&gt;

&lt;p&gt;Many beginners try to memorize pattern programs.&lt;/p&gt;

&lt;p&gt;That's the wrong approach.&lt;/p&gt;

&lt;p&gt;Instead, focus on understanding:&lt;/p&gt;

&lt;p&gt;What is changing in each iteration?&lt;/p&gt;

&lt;p&gt;Once you understand that, any pattern becomes easy to build.&lt;/p&gt;

&lt;p&gt;Let's look at some examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 1: Repeating the Same Number
&lt;/h2&gt;

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

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The loop runs 5 times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We always print 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The variable no is only used to count the iterations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern 2: Counting Numbers
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 2 3 4 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We start from 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After every iteration, we increase the value by 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The loop stops when the value becomes greater than 5.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern 3: Odd Numbers
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 3 5 7 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Odd numbers have a difference of 2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instead of increasing by 1, we increase by 2.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern 4: Multiples of 3
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 6 9 12 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We start from 3.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every next value is 3 more than the previous value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern 5: Reverse Multiples of 3
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15 12 9 6 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We start from the largest value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instead of incrementing, we decrement by 3.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern 6: Reverse Even Numbers
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10 8 6 4 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We begin with 10.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every iteration subtracts 2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This produces even numbers in reverse order.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pattern 7: Reverse Odd Numbers
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;9 7 5 3 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We start from the largest odd number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We subtract 2 in every iteration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The sequence continues until 1.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Hidden Pattern Behind All Patterns
&lt;/h2&gt;

&lt;p&gt;If you look carefully, every program follows the same structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;starting_value&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;update_value&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only things that change are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Starting value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Condition&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increment or decrement&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;Once you understand these three components, creating new patterns becomes much easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Pattern programs are not about printing numbers on the screen. They are exercises that train your brain to recognize sequences, understand loop behavior, and think logically.&lt;/p&gt;

&lt;p&gt;The moment you stop memorizing patterns and start identifying what changes in each iteration, you'll be able to create your own patterns confidently.&lt;/p&gt;

&lt;p&gt;Learn the logic, not the pattern. That's where real programming begins.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>python</category>
      <category>learning</category>
    </item>
    <item>
      <title>Java Constructors Demystified: What Happens Before Your Object Exists?</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Tue, 02 Jun 2026 14:50:36 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/java-constructors-demystified-what-happens-before-your-object-exists-5h9c</link>
      <guid>https://dev.to/hariharan_sj_2003/java-constructors-demystified-what-happens-before-your-object-exists-5h9c</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever wondered what actually happens when you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Noodles"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We all know that an object gets created. But what happens behind the scenes? Where does the memory come from? When are the values assigned? And why does Java automatically call a constructor without us explicitly invoking it?&lt;/p&gt;

&lt;p&gt;When I first learned constructors, I thought they were just special methods used to initialize objects. But after experimenting with object creation, default values, the this keyword, and constructor parameters, I discovered that constructors are much more than that—they are the starting point of an object's lifecycle.&lt;/p&gt;

&lt;p&gt;In this blog, we'll go beyond the textbook definition of constructors. We'll explore what really happens when an object is created, why this is important, how Java assigns default values, and some beginner mistakes that can silently break your code.&lt;/p&gt;

&lt;p&gt;By the end of this article, you'll not only know what a constructor is, but also why it behaves the way it does behind the scenes.&lt;/p&gt;

&lt;p&gt;Let's create our first object and uncover the magic that happens the moment we use the new keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  2.What is a Constructor?
&lt;/h2&gt;

&lt;p&gt;A constructor is used in the creation of an object that is an instance of a class. Typically it performs operations required to initialize the class before methods are invoked or fields are accessed. Constructors are never inherited.&lt;/p&gt;

&lt;p&gt;A constructor in Java is a special member that is called when an object is created. It initializes the new object’s state. It is used to set default or user-defined values for the object's attributes&lt;/p&gt;

&lt;p&gt;A constructor in Java is a special method that is used to initialize objects.&lt;/p&gt;

&lt;p&gt;The constructor is called when an object of a class is created.&lt;/p&gt;

&lt;p&gt;It can be used to set initial values for object attributes:&lt;/p&gt;

&lt;p&gt;A constructor is a special block of code that runs automatically whenever an object is created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Constructor Called"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating an Object&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Constructor Called
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The moment the object is created using the new keyword, Java automatically invokes the constructor.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.Rules of a Constructor
&lt;/h2&gt;

&lt;p&gt;A constructor has a few important rules:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Constructor name must be the same as the class name&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Constructors do not have a return type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Correct&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Incorrect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second example is not a constructor. It is a normal method.&lt;/p&gt;

&lt;h2&gt;
  
  
  4.Why Do We Need Constructors?
&lt;/h2&gt;

&lt;p&gt;Imagine creating an object and manually assigning values every time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;product1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Noodles"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;product1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;product2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Shampoo"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;product2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works, but it becomes repetitive.&lt;/p&gt;

&lt;p&gt;Instead, constructors allow us to initialize object-specific values immediately during object creation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can simply write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Noodles"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Shampoo"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cleaner, safer, and easier to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.Why Is the Constructor Called Twice?
&lt;/h2&gt;

&lt;p&gt;Consider this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"abc"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="n"&gt;product2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"xyz"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Are you constructor?"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Are you constructor?
Are you constructor?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many beginners get confused here.&lt;/p&gt;

&lt;p&gt;The reason is simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;One object = One constructor call&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Two objects = Two constructor calls&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every time you use the new keyword, Java creates a new object and invokes the constructor.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.The Mystery of this
&lt;/h2&gt;

&lt;p&gt;Consider the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;refers to the instance variable.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;refers to the constructor parameter.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;instanceVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7.What Happens If We Remove this?
&lt;/h2&gt;

&lt;p&gt;Suppose we write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, it looks correct.&lt;/p&gt;

&lt;p&gt;But Java interprets it as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;parameter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;parameter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The instance variables never receive the values.&lt;/p&gt;

&lt;h2&gt;
  
  
  8.Then Why Do We See null and 0?
&lt;/h2&gt;

&lt;p&gt;Let's look at the class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though we never assigned values, Java still prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;null
0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Because Java automatically assigns default values to instance variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  9.What Actually Happens During Object Creation?
&lt;/h2&gt;

&lt;p&gt;When Java executes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Noodles"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The JVM follows these steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Memory is allocated for the object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Default values are assigned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = null
price = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Field initializers are executed (if any).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Python"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Constructor executes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;SuperMarket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Final flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Object Creation
       ↓
Default Values
       ↓
Field Initializers
       ↓
Constructor Execution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This order is extremely important for understanding how Java objects are initialized.&lt;/p&gt;

&lt;h2&gt;
  
  
  10.Final Takeaway
&lt;/h2&gt;

&lt;p&gt;A constructor is not just a special method—it is the starting point of an object's life cycle.&lt;/p&gt;

&lt;p&gt;Whenever an object is created:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Memory is allocated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default values are assigned.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Field initializers run.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The constructor executes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The object becomes ready for use.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding constructors also helps you understand other important concepts like this, object initialization, inheritance, and &lt;strong&gt;super() TBD&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you're learning Java, mastering constructors is one of the best investments you can make before moving deeper into Object-Oriented Programming.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>backend</category>
    </item>
    <item>
      <title>Strong Java Starts with Strong Fundamentals</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Fri, 29 May 2026 06:26:01 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/strong-java-starts-with-strong-fundamentals-10ke</link>
      <guid>https://dev.to/hariharan_sj_2003/strong-java-starts-with-strong-fundamentals-10ke</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Programming languages come and go. Technologies change every year.&lt;br&gt;
But even after decades, Java still powers millions of applications around the world — from banking systems and Android apps to enterprise software used by giant companies.&lt;/p&gt;

&lt;p&gt;The interesting part?&lt;br&gt;
Every advanced Java application starts with just a few basic concepts.&lt;/p&gt;

&lt;p&gt;Before learning frameworks, APIs, or backend development, every Java developer must first understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How classes are declared&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What data types actually mean&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How fields store and manage data inside objects&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These may look like beginner topics, but they form the backbone of Java programming. If these fundamentals are strong, learning advanced concepts becomes much easier.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll break down Java classes, primitive and non-primitive data types, and fields in a simple and beginner-friendly way with clear examples.&lt;/p&gt;
&lt;h2&gt;
  
  
  2.Classes, Data Types, and Fields in Java
&lt;/h2&gt;

&lt;p&gt;Java is one of the most popular programming languages in the world. From Android apps to enterprise software, Java is used everywhere because of its simplicity, security, and platform independence.&lt;/p&gt;

&lt;p&gt;Before building real-world applications, every Java developer must understand three important fundamentals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How to declare a class correctly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Types of data types in Java&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What fields are and how they work&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s explore them one by one.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Rules for Declaring a Class in Java
&lt;/h2&gt;

&lt;p&gt;A class is the blueprint of an object.&lt;br&gt;
In Java, everything revolves around classes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4.Important Rules for Declaring a Class
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Class Name Should Start with a Letter&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Employee&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="err"&gt;123&lt;/span&gt;&lt;span class="nc"&gt;Employee&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Java is Case Sensitive&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both are considered different classes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Spaces Are Not Allowed in Class Names&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;My&lt;/span&gt; &lt;span class="nc"&gt;Class&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Special Characters Are Not Allowed (Except _ and $)&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student_Data&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="nd"&gt;@Data&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. File Name and Public Class Name Must Be Same&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file name must be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Car.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Otherwise Java will throw an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  4.Data Types in Java
&lt;/h2&gt;

&lt;p&gt;Data types define what kind of value a variable can store.&lt;/p&gt;

&lt;p&gt;Java mainly has two categories of data types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Primitive Data Types&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-Primitive Data Types&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Primitive Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Primitive data types are predefined by Java.&lt;br&gt;
They store simple values directly.&lt;/p&gt;

&lt;p&gt;Java has 8 primitive data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. byte&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;byte&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 1 byte&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. short&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The short data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;short&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 2 bytes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. int&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, the int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 232-1. Use the Integer class to use int data type as an unsigned integer. See the section The Number Classes for more information. Static methods like compareUnsigned, divideUnsigned etc have been added to the Integer class to support the arithmetic operations for unsigned integers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 4 bytes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. long&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The long data type is a 64-bit two's complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1. Use this data type when you need a range of values wider than those provided by int. The Long class also contains methods like compareUnsigned, divideUnsigned etc to support arithmetic operations for unsigned long.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8000000000L&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 8 bytes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. float&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead. Numbers and Strings covers BigDecimal and other useful classes provided by the Java platform.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;99.5f&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 4 bytes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. double&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.141592653&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 8 bytes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. char&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'A'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Size: 2 bytes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. boolean&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;isJavaFun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Non-Primitive Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Non-primitive data types are created by programmers or provided by Java.&lt;/p&gt;

&lt;p&gt;They store references instead of actual values.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;String&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arrays (TBD)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Classes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interfaces (TBD)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Objects&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Non-primitive data types are called reference types because they refer to objects.&lt;/p&gt;

&lt;p&gt;The main differences between primitive and non-primitive data types are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Primitive types in Java are predefined and built into the language, while non-primitive types are created by the programmer (except for String).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-primitive types can be used to call methods to perform certain operations, whereas primitive types cannot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Primitive types start with a lowercase letter (like int), while non-primitive types typically starts with an uppercase letter (like String).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Primitive types always hold a value, whereas non-primitive types can be null.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;String Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hari"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Class Object Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5.Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Every expert Java developer once started with the basics.&lt;br&gt;
Understanding classes, data types, and fields may seem simple at first, but these concepts are the foundation of everything you build in Java.&lt;/p&gt;

&lt;p&gt;A class gives structure to your program.&lt;br&gt;
Data types help Java understand and manage data efficiently.&lt;br&gt;
Fields define the properties that make every object unique.&lt;/p&gt;

&lt;p&gt;When your fundamentals are strong, learning advanced topics like objects, constructors, inheritance, collections, JDBC, Spring Boot, and backend development becomes much easier.&lt;/p&gt;

&lt;p&gt;So don’t rush through the basics.&lt;br&gt;
Master them.&lt;/p&gt;

&lt;p&gt;Because strong Java developers are built on strong fundamentals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html" rel="noopener noreferrer"&gt;https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://www.w3schools.com/java/java_data_types_non-prim.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/java/java_data_types_non-prim.asp&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>backend</category>
    </item>
    <item>
      <title>From Railway Stations to Police Chase — Master Python While Loops</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Thu, 28 May 2026 11:17:26 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/from-railway-stations-to-police-chase-master-python-while-loops-2cc7</link>
      <guid>https://dev.to/hariharan_sj_2003/from-railway-stations-to-police-chase-master-python-while-loops-2cc7</guid>
      <description>&lt;h2&gt;
  
  
  1.Mastering while Loops in Python with Real-Time Examples
&lt;/h2&gt;

&lt;p&gt;Programming becomes interesting when we connect logic with real-world situations.&lt;br&gt;
Instead of learning loops with boring numbers, let’s understand Python while loops using practical examples like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Finding railway stations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Detecting common multiples&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Catching a thief&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this blog, we’ll break down multiple Python programs step-by-step and understand how loops actually work behind the scenes.&lt;/p&gt;
&lt;h2&gt;
  
  
  2.Example 1 — Finding Numbers Divisible by 3 and 5
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;station_no&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15
30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;station_no starts from 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The loop runs until 30&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We check:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AND&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If both are true, the number is printed.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.What Does % Mean?
&lt;/h2&gt;

&lt;p&gt;% is called the modulus operator.&lt;/p&gt;

&lt;p&gt;It returns the remainder.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15 % 3 = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because 15 is perfectly divisible by 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  4.Example 2 — Finding the First Matching Station using break
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;station_no&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  5.What is break?
&lt;/h2&gt;

&lt;p&gt;The break statement in Python is used to exit or "break" out of a loop (either for or while loop) prematurely, before the loop has iterated through all its items or reached its condition. When the break statement is executed, the program immediately exits the loop, and the control moves to the next line of code after the loop.&lt;/p&gt;

&lt;p&gt;The break keyword is used to break out a for loop, or a while loop.&lt;/p&gt;

&lt;p&gt;Without break, the loop would print:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15
30
45
60
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But with break, the loop stops after finding the first matching value.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.Example 3 — Unknown Number of Stations using while True
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Total no. of stations unknown
&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;62&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;station_no&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;station_no&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why while True?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes we don't know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;how many times the loop should run&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;where the answer exists&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we create an infinite loop using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then stop it manually using break.&lt;/p&gt;

&lt;h2&gt;
  
  
  7.Example 4 — Police Catching a Thief
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="n"&gt;thief&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;thief&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;thief&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;police&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Concept Behind the Program&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a beautiful real-world simulation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Police speed increases by 5&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thief speed increases by 2&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The loop runs continuously.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;thief&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The thief gets caught.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Note&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before running this program, initialize the variables.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;thief&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Complete Program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;thief&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="n"&gt;thief&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;thief&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;police&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;thief&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;police&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  8.Why These Programs Matter
&lt;/h2&gt;

&lt;p&gt;Most beginners think loops are difficult.&lt;/p&gt;

&lt;p&gt;But once you connect loops with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;trains&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;stations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;police chase&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;real-time logic&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Programming becomes much easier and more fun.&lt;/p&gt;

&lt;h2&gt;
  
  
  9.Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The while loop is one of the most powerful concepts in Python.&lt;/p&gt;

&lt;p&gt;Whether you're:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;searching for values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;building games&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;creating simulations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;solving real-world problems&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;while loops are everywhere.&lt;/p&gt;

&lt;p&gt;The best way to master loops is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Practice&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visualize&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build logic gradually&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because programming is not about memorizing syntax —&lt;br&gt;
it’s about training your thinking process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://www.geeksforgeeks.org/python/python-break-statement/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/python/python-break-statement/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://www.w3schools.com/python/ref_keyword_break.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/python/ref_keyword_break.asp&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>coding</category>
      <category>python</category>
    </item>
    <item>
      <title>The One Concept That Powers Every Java Application</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Wed, 27 May 2026 11:53:57 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/the-one-concept-that-powers-every-java-application-3p3o</link>
      <guid>https://dev.to/hariharan_sj_2003/the-one-concept-that-powers-every-java-application-3p3o</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Imagine trying to build an application like Instagram, Amazon, or a banking system using thousands of random functions and unorganized code. Sounds impossible, right? &lt;/p&gt;

&lt;p&gt;As software applications started becoming larger and more complex, developers needed a smarter way to organize code — something that was secure, reusable, scalable, and easier to maintain.&lt;/p&gt;

&lt;p&gt;That’s where Object-Oriented Programming (OOPs) changed everything. &lt;/p&gt;

&lt;p&gt;OOPs is not just a programming concept in Java.&lt;br&gt;
It is the foundation behind how modern software is designed.&lt;/p&gt;

&lt;p&gt;From mobile apps  to enterprise systems , Java uses OOPs to model real-world entities like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Users&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cars&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bank Accounts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Employees&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shopping Carts&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;into reusable software objects.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll deeply explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Why OOPs is needed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The four pillars of OOPs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Internal working of classes and objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-world examples&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How Java uses OOPs internally&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this article, you won’t just memorize OOPs concepts — you’ll actually understand why they are the backbone of Java development.&lt;/p&gt;
&lt;h2&gt;
  
  
  2.What is OOPs?
&lt;/h2&gt;

&lt;p&gt;Object-Oriented Programming System (OOPs) is a programming approach where everything is organized around objects and classes.&lt;/p&gt;

&lt;p&gt;Instead of writing long procedural code, OOPs allows developers to model real-world entities like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cars&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Students&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bank Accounts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Employees&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;as software objects.&lt;/p&gt;
&lt;h2&gt;
  
  
  3.Why OOPs Concept is Needed in Java?
&lt;/h2&gt;

&lt;p&gt;Imagine building a very large application like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Instagram&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Amazon&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Banking Systems&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hospital Management Systems&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without proper structure, the code would become:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Messy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Difficult to manage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hard to debug&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unsafe&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Impossible to scale&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly why Object-Oriented Programming (OOPs) was introduced.&lt;/p&gt;

&lt;p&gt;OOPs helps developers organize software in a smarter and more realistic way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Main Problem Before OOPs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before OOPs, many programming languages mainly followed:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Procedural Programming&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In procedural programming:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Everything is written as functions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data is shared globally&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Programs become harder to maintain as size increases&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example of Procedural Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine creating a banking application.&lt;/p&gt;

&lt;p&gt;You may have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deposit()
withdraw()
checkBalance()
transferMoney()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All functions directly access shared data.&lt;/p&gt;

&lt;p&gt;As the application grows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Bugs increase&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security issues appear&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code duplication happens&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintenance becomes difficult&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For small programs this is okay.&lt;/p&gt;

&lt;p&gt;But for real-world applications with millions of users, this becomes a disaster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why OOPs Was Introduced&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OOPs was introduced to solve these real software development problems.&lt;/p&gt;

&lt;p&gt;It helps developers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Organize code properly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reuse existing code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improve security&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce complexity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build scalable applications&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Model real-world entities&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4.Understanding Class and Object
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A class is a blueprint or template for creating objects.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
    String brand;
    int speed;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, Car is a class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An object is an instance of a class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Car c1 = new Car();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, c1 is an object of the Car class.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.The Four Pillars of OOPs
&lt;/h2&gt;

&lt;p&gt;These are the core concepts that define Object-Oriented Programming:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Encapsulation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inheritance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Polymorphism&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstraction&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Encapsulation&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Encapsulation means:&lt;/p&gt;

&lt;p&gt;Wrapping data and methods together into a single unit.&lt;/p&gt;

&lt;p&gt;It also means restricting direct access to sensitive data.&lt;/p&gt;

&lt;p&gt;In Java, encapsulation is achieved using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Private variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Public getter and setter methods&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Encapsulation is Important?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine a bank account.&lt;/p&gt;

&lt;p&gt;If everyone could directly access your balance variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;balance = -100000;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the system would become unsafe.&lt;/p&gt;

&lt;p&gt;Encapsulation protects data from unauthorized modification.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Encapsulation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Student {

    private int marks;

    public void setMarks(int m) {

        if(m &amp;gt;= 0 &amp;amp;&amp;amp; m &amp;lt;= 100) {
            marks = m;
        }
    }

    public int getMarks() {
        return marks;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Inheritance&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Inheritance allows one class to acquire the properties and behaviors of another class.&lt;/p&gt;

&lt;p&gt;The existing class is called:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Parent Class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Super Class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Base Class&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The new class is called:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Child Class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sub Class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Derived Class&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Without inheritance, developers would repeatedly write the same code.&lt;/p&gt;

&lt;p&gt;Inheritance promotes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Code Reusability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintainability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hierarchical Relationships&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example of Inheritance&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal {

    void eat() {
        System.out.println("Animal eats food");
    }
}

- 
class Dog extends Animal {

    void bark() {
        System.out.println("Dog barks");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Polymorphism&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Polymorphism means:&lt;/p&gt;

&lt;p&gt;One entity behaving in multiple forms.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;A person can behave differently as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Student&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Employee&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customer&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarly, Java methods can behave differently depending on the situation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Polymorphism&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Method Overloading (TBD)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method Overriding (TBD)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;4. Abstraction&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Abstraction means:&lt;/p&gt;

&lt;p&gt;Hiding internal implementation and showing only essential features.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;You drive a car using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Steering&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Brake&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accelerator&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But you don’t see internal engine mechanisms.&lt;/p&gt;

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

&lt;p&gt;Without abstraction, systems become extremely complex.&lt;/p&gt;

&lt;p&gt;Abstraction reduces complexity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abstract class Vehicle {

    abstract void start();

    void stop() {
        System.out.println("Vehicle stopped");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6.Final Conclusion
&lt;/h2&gt;

&lt;p&gt;OOPs is not just a programming topic.&lt;/p&gt;

&lt;p&gt;It is a software design philosophy that helps developers create clean, maintainable, reusable, and scalable applications.&lt;/p&gt;

&lt;p&gt;To truly master Java, understanding these concepts deeply is essential:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Encapsulation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inheritance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Polymorphism&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstraction&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once these concepts become clear, writing advanced Java applications becomes much easier.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Java Isn’t Just a Language — It’s an Ecosystem</title>
      <dc:creator>Hariharan S J</dc:creator>
      <pubDate>Tue, 26 May 2026 12:42:07 +0000</pubDate>
      <link>https://dev.to/hariharan_sj_2003/java-isnt-just-a-language-its-an-ecosystem-1o62</link>
      <guid>https://dev.to/hariharan_sj_2003/java-isnt-just-a-language-its-an-ecosystem-1o62</guid>
      <description>&lt;h2&gt;
  
  
  1.Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever wondered how the same Java program runs perfectly on Windows, Linux, and macOS without changing a single line of code?&lt;/p&gt;

&lt;p&gt;That’s the magic of Java Architecture.&lt;/p&gt;

&lt;p&gt;Behind every Java application, powerful components like JVM, JDK, JRE, Bytecode, and JIT Compiler work together to make Java secure, portable, and incredibly powerful.&lt;/p&gt;

&lt;p&gt;But most beginners use Java without actually understanding what happens internally when a Java program runs.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll break down the complete architecture of Java in a simple and beginner-friendly way. From the history of Java to understanding how bytecode works and why Java follows the famous principle:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Write Once, Run Anywhere”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You’ll learn everything you need to build a strong foundation in Java.&lt;/p&gt;

&lt;h2&gt;
  
  
  2.Origin of Java
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdh0kceoswgihexjfcfz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdh0kceoswgihexjfcfz.jpg" alt=" " width="669" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feq4n7jjt9vb5yaqptiia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feq4n7jjt9vb5yaqptiia.png" alt=" " width="631" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Java was developed by James Gosling and his team at Sun Microsystems in the early 1990s.&lt;/p&gt;

&lt;p&gt;The project started in 1991.&lt;/p&gt;

&lt;p&gt;The main members of the Java team were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;James Gosling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mike Sheridan&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Patrick Naughton&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This team was later called the Green Team.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.Why Was Java Created?
&lt;/h2&gt;

&lt;p&gt;Initially, Java was developed for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Television systems&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Embedded devices&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Electronic appliances&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal was to create a language that could run on multiple devices without modification.&lt;/p&gt;

&lt;p&gt;At that time, existing languages were platform dependent.&lt;/p&gt;

&lt;p&gt;The Green Team wanted a language that followed:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Write Once, Run Anywhere”&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4.What is Java?
&lt;/h2&gt;

&lt;p&gt;Java is a high-level, object-oriented programming language developed by Oracle Corporation.&lt;/p&gt;

&lt;p&gt;Java is designed to be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simple&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secure&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Portable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Platform Independent&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Java Program Execution Flow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxj13050bqck14wuwtsd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxj13050bqck14wuwtsd.png" alt=" " width="634" height="497"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Java Source Code (.java)
        ↓
Compiler (javac)
        ↓
Bytecode (.class)
        ↓
JVM
        ↓
Machine Code
        ↓
Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5.What is JDK?
&lt;/h2&gt;

&lt;p&gt;JDK → Java Development Kit&lt;/p&gt;

&lt;p&gt;JDK is a complete package used for developing Java applications.&lt;/p&gt;

&lt;p&gt;It provides all the tools required to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Write Java programs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compile Java code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run Java applications&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debug programs&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Components of JDK&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JDK contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JRE&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Java Compiler (javac)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debugging tools&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Documentation tools&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Development utilities&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Formula&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JDK = JRE + Development Tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6.Why JDK is Important?
&lt;/h2&gt;

&lt;p&gt;Without JDK, developers cannot create Java applications because it contains the compiler needed to convert source code into bytecode.&lt;/p&gt;

&lt;h2&gt;
  
  
  7.What is Bytecode?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Bytecode Definition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bytecode is the intermediate code generated after compiling a Java program.&lt;/p&gt;

&lt;p&gt;When we compile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javac Hello.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello.class
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This .class file contains bytecode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Bytecode is Important?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bytecode is platform independent.&lt;/p&gt;

&lt;p&gt;This means the same bytecode can run on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Windows&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linux&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;macOS&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the core reason behind Java’s portability.&lt;/p&gt;

&lt;h2&gt;
  
  
  8.What is JVM?
&lt;/h2&gt;

&lt;p&gt;JVM → Java Virtual Machine&lt;/p&gt;

&lt;p&gt;JVM is the heart of Java Architecture.&lt;/p&gt;

&lt;p&gt;It converts bytecode into machine code and executes the program.&lt;/p&gt;

&lt;p&gt;JVM acts as a bridge between Java applications and the operating system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsibilities of JVM&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Loads class files&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verifies bytecode&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Executes code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Allocates memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performs Garbage Collection&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  9.What is JIT Compiler?
&lt;/h2&gt;

&lt;p&gt;JIT → Just-In-Time Compiler&lt;/p&gt;

&lt;p&gt;The JIT Compiler improves Java performance.&lt;/p&gt;

&lt;p&gt;Instead of interpreting the same bytecode repeatedly, JIT converts frequently used bytecode into native machine code.&lt;/p&gt;

&lt;p&gt;This makes Java programs faster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How JIT Works?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Without JIT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bytecode → Interpreter → Execution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With JIT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bytecode → JIT Compiler → Native Machine Code → Faster Execution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advantages of JIT Compiler&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Improves performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduces execution time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimizes frequently used code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Makes Java applications faster&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  10.What is JRE?
&lt;/h2&gt;

&lt;p&gt;JRE → Java Runtime Environment&lt;/p&gt;

&lt;p&gt;JRE provides the environment required to run Java applications.&lt;/p&gt;

&lt;p&gt;It contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JVM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Core libraries&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supporting files&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Formula&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JRE = JVM + Libraries
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why JRE is Important?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you only want to run Java applications and not develop them, JRE is enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  11.Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Understanding concepts like JDK, JVM, JRE, Bytecode, and JIT Compiler is essential for every Java developer.&lt;/p&gt;

&lt;p&gt;These concepts explain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How Java programs execute&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why Java is platform independent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How Java manages memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How Java achieves performance&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand Java Architecture deeply, learning advanced Java concepts becomes much easier.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
