<?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: M.Kabileshwaran</title>
    <description>The latest articles on DEV Community by M.Kabileshwaran (@mkabileshwaran).</description>
    <link>https://dev.to/mkabileshwaran</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%2F3206150%2Fed58dd1a-0b20-4f6e-bce4-55249176022e.png</url>
      <title>DEV Community: M.Kabileshwaran</title>
      <link>https://dev.to/mkabileshwaran</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mkabileshwaran"/>
    <language>en</language>
    <item>
      <title>I Created a Structured JavaScript and React Learning Repository as Part of My Learning Journey</title>
      <dc:creator>M.Kabileshwaran</dc:creator>
      <pubDate>Sun, 26 Jul 2026 08:51:35 +0000</pubDate>
      <link>https://dev.to/mkabileshwaran/i-created-a-structured-javascript-and-react-learning-repository-as-part-of-my-learning-journey-dik</link>
      <guid>https://dev.to/mkabileshwaran/i-created-a-structured-javascript-and-react-learning-repository-as-part-of-my-learning-journey-dik</guid>
      <description>&lt;p&gt;Learning frontend development can sometimes feel overwhelming.&lt;/p&gt;

&lt;p&gt;There are countless tutorials, courses, and resources available online, but one challenge I faced was finding a structured path where I could learn concepts step by step, practice them properly, and understand the reasoning behind each concept.&lt;/p&gt;

&lt;p&gt;As a Computer Science student, I wanted to move away from only following tutorials and start building my own learning system.&lt;/p&gt;

&lt;p&gt;So I started creating:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn Frontend&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/KabileshwaranKabil" rel="noopener noreferrer"&gt;
        KabileshwaranKabil
      &lt;/a&gt; / &lt;a href="https://github.com/KabileshwaranKabil/learn-frontend" rel="noopener noreferrer"&gt;
        learn-frontend
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A personal learning repo documenting my journey from JavaScript fundamentals to React development
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Learn Frontend&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;A structured self-learning repository to master frontend development through detailed notes, practice code, experiments, and projects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;About This Repository&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Learn Frontend&lt;/strong&gt; is a comprehensive learning repository created to learn modern frontend development from the basics.&lt;/p&gt;
&lt;p&gt;This repository is designed for anyone who wants to learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;JavaScript from fundamentals&lt;/li&gt;
&lt;li&gt;React.js from the basics&lt;/li&gt;
&lt;li&gt;Modern frontend development concepts&lt;/li&gt;
&lt;li&gt;Building real-world frontend applications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;No previous frontend experience is required.&lt;/p&gt;
&lt;p&gt;The learning journey starts from the foundation and gradually builds towards advanced frontend development through a structured, module-based approach.&lt;/p&gt;
&lt;p&gt;The purpose of this repository is not just to memorize syntax, but to understand:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why concepts exist&lt;/li&gt;
&lt;li&gt;How concepts work internally&lt;/li&gt;
&lt;li&gt;How different technologies connect together&lt;/li&gt;
&lt;li&gt;How to apply knowledge through practical development&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Learning Approach&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;This repository follows a step-by-step learning approach.&lt;/p&gt;
&lt;p&gt;Each concept is divided into smaller learning modules, allowing learners to understand, practice, and apply concepts gradually.&lt;/p&gt;
&lt;p&gt;The learning process:&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;
&lt;pre class="notranslate"&gt;&lt;code&gt;Understand&lt;/code&gt;&lt;/pre&gt;…&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/KabileshwaranKabil/learn-frontend" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;This is my personal learning repository where I document my journey of learning JavaScript and React.&lt;/p&gt;

&lt;p&gt;The repository includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structured learning notes&lt;/li&gt;
&lt;li&gt;Code examples&lt;/li&gt;
&lt;li&gt;Practice exercises&lt;/li&gt;
&lt;li&gt;Concept explanations&lt;/li&gt;
&lt;li&gt;Small experiments&lt;/li&gt;
&lt;li&gt;Projects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My approach is simple:&lt;/p&gt;

&lt;p&gt;Understand the concept → Take notes → Practice → Experiment → Build&lt;/p&gt;

&lt;p&gt;The content is created using official documentation and other free learning resources available online, combined with my own understanding and explanations.&lt;/p&gt;

&lt;p&gt;This repository is still evolving because I am also learning while building it. New concepts, improvements, and projects will continue to be added.&lt;/p&gt;

&lt;p&gt;I am sharing this with the community because I believe learning becomes more meaningful when knowledge is shared.&lt;/p&gt;

&lt;p&gt;If you are a beginner starting your frontend journey, I hope this can help you learn in a more structured and effective way.&lt;/p&gt;

&lt;p&gt;If you are an experienced developer, your feedback, suggestions, and contributions are highly appreciated.&lt;/p&gt;

&lt;p&gt;Feel free to contribute, improve explanations, add examples, or suggest better ways to help other learners.&lt;/p&gt;

&lt;p&gt;Learning together makes the journey better.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Spring Security for Beginners — Authentication, Authorization &amp; Basic Setup</title>
      <dc:creator>M.Kabileshwaran</dc:creator>
      <pubDate>Wed, 22 Jul 2026 11:00:11 +0000</pubDate>
      <link>https://dev.to/mkabileshwaran/spring-security-for-beginners-authentication-authorization-basic-setup-1c1l</link>
      <guid>https://dev.to/mkabileshwaran/spring-security-for-beginners-authentication-authorization-basic-setup-1c1l</guid>
      <description>&lt;p&gt;I'm currently learning &lt;strong&gt;Spring Security&lt;/strong&gt;, and these are my beginner-friendly notes after understanding the fundamentals. I wanted to organize everything into one place so it can help other students who are just getting started.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is Spring Security?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Spring Security&lt;/strong&gt; is a security framework for Spring Boot applications. It helps protect your application by handling two major responsibilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authentication&lt;/strong&gt; – Verifying who the user is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorization&lt;/strong&gt; – Deciding what the authenticated user is allowed to access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the three topics I learned first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fundamentals&lt;/li&gt;
&lt;li&gt;Basic Setup&lt;/li&gt;
&lt;li&gt;Authorization Rules&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Authentication vs Authorization
&lt;/h1&gt;

&lt;p&gt;Let's understand this with a simple example.&lt;/p&gt;

&lt;p&gt;Imagine &lt;strong&gt;Nimethan&lt;/strong&gt;, a university student, logging into the university portal.&lt;/p&gt;

&lt;p&gt;He enters his &lt;strong&gt;username and password&lt;/strong&gt;, and the system verifies his credentials before allowing him to log in.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;Authentication&lt;/strong&gt; — verifying &lt;strong&gt;who the user is&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After logging in, Nimethan can &lt;strong&gt;view his own grades&lt;/strong&gt;, but he &lt;strong&gt;cannot modify them&lt;/strong&gt; or access another student's records because he is only a student.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;Authorization&lt;/strong&gt; — deciding &lt;strong&gt;what the authenticated user is allowed to do&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Authentication
&lt;/h1&gt;

&lt;p&gt;Authentication answers the question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Who are you?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;ul&gt;
&lt;li&gt;Logging in with a username and password&lt;/li&gt;
&lt;li&gt;Verifying user identity&lt;/li&gt;
&lt;li&gt;Creating an authenticated session&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Authorization
&lt;/h1&gt;

&lt;p&gt;Authorization answers the question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"What are you allowed to do?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;ul&gt;
&lt;li&gt;Accessing &lt;code&gt;/admin&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Viewing protected resources&lt;/li&gt;
&lt;li&gt;Checking user roles and permissions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If a normal user tries to access an admin endpoint, Spring Security checks whether that user has the required role before granting access.&lt;/p&gt;




&lt;h1&gt;
  
  
  Basic Setup
&lt;/h1&gt;

&lt;p&gt;When Spring Security is added to a Spring Boot project, &lt;strong&gt;every endpoint becomes protected by default&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 — Add the dependency
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-starter-security&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding the dependency and running the application, visiting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;redirects you to Spring Security's default login page.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0kk3yj5gaa6wqxhdv0mc.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0kk3yj5gaa6wqxhdv0mc.png" alt=" " width="542" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Spring Boot automatically creates a temporary user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default Username&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;user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Default Password&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The password is printed in the application console every time the application starts.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9cofuoqvaz2g7odac4j9.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9cofuoqvaz2g7odac4j9.png" alt=" " width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 2 — Create a Security Configuration
&lt;/h1&gt;

&lt;p&gt;Create a class called &lt;code&gt;SecurityConfig.java&lt;/code&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="nd"&gt;@EnableWebSecurity&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;SecurityConfig&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Bean&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;SecurityFilterChain&lt;/span&gt; &lt;span class="nf"&gt;filterChain&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpSecurity&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="n"&gt;http&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;authorizeHttpRequests&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;anyRequest&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;authenticated&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;formLogin&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;withDefaults&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&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 configuration means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every request requires authentication.&lt;/li&gt;
&lt;li&gt;Spring Security provides the default login page.&lt;/li&gt;
&lt;li&gt;All security rules are managed through a &lt;code&gt;SecurityFilterChain&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Understanding the Security Configuration
&lt;/h1&gt;

&lt;h2&gt;
  
  
  @EnableWebSecurity
&lt;/h2&gt;

&lt;p&gt;Enables Spring Security's web security support and tells Spring that you want to customize the security configuration instead of relying only on the defaults.&lt;/p&gt;




&lt;h2&gt;
  
  
  SecurityConfig
&lt;/h2&gt;

&lt;p&gt;A regular Java configuration class where all security rules are defined.&lt;/p&gt;

&lt;p&gt;You can think of it as the application's &lt;strong&gt;security blueprint&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Bean
&lt;/h2&gt;

&lt;p&gt;Marks a method whose returned object will be managed by Spring.&lt;/p&gt;

&lt;p&gt;Here, we're telling Spring to use our custom &lt;code&gt;SecurityFilterChain&lt;/code&gt; for handling security.&lt;/p&gt;




&lt;h2&gt;
  
  
  SecurityFilterChain
&lt;/h2&gt;

&lt;p&gt;This is the modern way to configure Spring Security.&lt;/p&gt;

&lt;p&gt;It replaces the older &lt;code&gt;WebSecurityConfigurerAdapter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A filter chain is simply a sequence of security filters that process every incoming HTTP request before it reaches your controller.&lt;/p&gt;




&lt;h2&gt;
  
  
  HttpSecurity
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;HttpSecurity&lt;/code&gt; provides methods for configuring your application's security.&lt;/p&gt;

&lt;p&gt;Some commonly used methods include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;authorizeHttpRequests()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;formLogin()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;httpBasic()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;logout()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;csrf()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  authorizeHttpRequests()
&lt;/h2&gt;

&lt;p&gt;Defines the authorization rules.&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="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;authorizeHttpRequests&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;anyRequest&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;authenticated&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 configuration tells Spring Security:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Every request must be authenticated before it can access any endpoint.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  formLogin(withDefaults())
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;formLogin&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;withDefaults&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enables Spring Security's default login page.&lt;/p&gt;

&lt;p&gt;When an unauthenticated user attempts to access a protected resource:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Spring redirects the user to the login page.&lt;/li&gt;
&lt;li&gt;The user enters their credentials.&lt;/li&gt;
&lt;li&gt;Spring authenticates the user.&lt;/li&gt;
&lt;li&gt;The authenticated user's information is stored inside the &lt;code&gt;SecurityContext&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Future requests recognize the logged-in user.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  http.build()
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This finalizes the security configuration and returns the &lt;code&gt;SecurityFilterChain&lt;/code&gt; bean that Spring Boot will use.&lt;/p&gt;

&lt;p&gt;Without calling &lt;code&gt;build()&lt;/code&gt;, the configuration would never be applied.&lt;/p&gt;




&lt;h1&gt;
  
  
  Request Flow
&lt;/h1&gt;

&lt;p&gt;Here's what happens when a user visits &lt;code&gt;/home&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The user requests &lt;code&gt;/home&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Spring Security checks the configured authorization rules.&lt;/li&gt;
&lt;li&gt;The endpoint requires authentication.&lt;/li&gt;
&lt;li&gt;Since the user is not logged in, Spring redirects them to the login page.&lt;/li&gt;
&lt;li&gt;The user enters valid credentials.&lt;/li&gt;
&lt;li&gt;Spring authenticates the user and stores the authentication information in the &lt;code&gt;SecurityContext&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The user is redirected back to &lt;code&gt;/home&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Authorization Rules
&lt;/h1&gt;

&lt;p&gt;In a real application, not every user should have the same level of access.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Users&lt;/strong&gt; → Can access general pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Admins&lt;/strong&gt; → Can access administrative pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where authorization rules become important.&lt;/p&gt;

&lt;p&gt;The basic process is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create users with different roles.&lt;/li&gt;
&lt;li&gt;Configure endpoint access rules.&lt;/li&gt;
&lt;li&gt;Create controllers.&lt;/li&gt;
&lt;li&gt;Test the application.&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Creating Multiple Users
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;UserDetailsService&lt;/span&gt; &lt;span class="nf"&gt;users&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;UserDetails&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"user"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;encode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"pass"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"USER"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="nc"&gt;UserDetails&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"admin"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;encode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"admin"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ADMIN"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&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;InMemoryUserDetailsManager&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;PasswordEncoder&lt;/span&gt; &lt;span class="nf"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;()&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;BCryptPasswordEncoder&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;h1&gt;
  
  
  Understanding the Classes
&lt;/h1&gt;

&lt;h2&gt;
  
  
  UserDetails
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;UserDetails&lt;/code&gt; represents a user that Spring Security can authenticate.&lt;/p&gt;

&lt;p&gt;It stores information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Username&lt;/li&gt;
&lt;li&gt;Password&lt;/li&gt;
&lt;li&gt;Roles&lt;/li&gt;
&lt;li&gt;Account status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&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;UserDetails&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"user"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passwordEncoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;encode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"pass"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"USER"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a user with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Username: &lt;code&gt;user&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Password: &lt;code&gt;pass&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Role: &lt;code&gt;USER&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  UserDetailsService
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;UserDetailsService&lt;/code&gt; is an interface used by Spring Security to retrieve user information during authentication.&lt;/p&gt;

&lt;p&gt;When a user attempts to log in, Spring Security asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Can you provide the user details for this username?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An implementation of this interface is responsible for returning the corresponding &lt;code&gt;UserDetails&lt;/code&gt; object.&lt;/p&gt;




&lt;h2&gt;
  
  
  InMemoryUserDetailsManager
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;InMemoryUserDetailsManager&lt;/code&gt; is a simple implementation of &lt;code&gt;UserDetailsService&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Instead of retrieving users from a database, it stores them directly in memory.&lt;/p&gt;

&lt;p&gt;This makes it ideal for learning, testing, and small demo applications.&lt;/p&gt;




&lt;h2&gt;
  
  
  PasswordEncoder
&lt;/h2&gt;

&lt;p&gt;Passwords should never be stored as plain text.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PasswordEncoder&lt;/code&gt; securely hashes passwords before storing them.&lt;/p&gt;

&lt;p&gt;In this example, we use:&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;BCryptPasswordEncoder&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which is one of the most commonly used password hashing algorithms in Spring Security.&lt;/p&gt;




&lt;p&gt;These are the core concepts I learned while getting started with Spring Security.&lt;/p&gt;

&lt;p&gt;Understanding &lt;strong&gt;Authentication&lt;/strong&gt;, &lt;strong&gt;Authorization&lt;/strong&gt;, and the &lt;strong&gt;SecurityFilterChain&lt;/strong&gt; makes it much easier to understand the more advanced topics that come next, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JWT Authentication&lt;/li&gt;
&lt;li&gt;Stateless Security&lt;/li&gt;
&lt;li&gt;Custom Login&lt;/li&gt;
&lt;li&gt;Role-Based Access Control (RBAC)&lt;/li&gt;
&lt;li&gt;OAuth2&lt;/li&gt;
&lt;li&gt;Method-Level Security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm still learning, so if you notice anything that could be improved or explained better, feel free to leave a comment. I'm always happy to learn from others.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>springsecurity</category>
      <category>beginners</category>
      <category>java</category>
    </item>
    <item>
      <title>OOP in Java: A First-Year Student’s Cheat Sheet</title>
      <dc:creator>M.Kabileshwaran</dc:creator>
      <pubDate>Wed, 02 Jul 2025 10:50:42 +0000</pubDate>
      <link>https://dev.to/mkabileshwaran/oop-in-java-a-first-year-students-cheat-sheet-3hao</link>
      <guid>https://dev.to/mkabileshwaran/oop-in-java-a-first-year-students-cheat-sheet-3hao</guid>
      <description>&lt;p&gt;Think of OOP like building with blueprints and real-world creations.&lt;br&gt;
&lt;strong&gt;1. Classes vs. Objects – The Simple Difference&lt;/strong&gt;&lt;br&gt;
A class is like a recipe for a cake. It lists the ingredients (data) and steps (actions). An object is the actual cake you bake using that recipe. You can make many cakes from one recipe, just like you can create many objects from one class.&lt;br&gt;
Example:&lt;br&gt;
Class (Recipe): "How to make a car" (has wheels, color, speed).&lt;br&gt;
Object (Real Car): Your red Toyota (with 4 wheels, going 60 mph).&lt;br&gt;
In Java:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class = blueprint or template&lt;/li&gt;
&lt;li&gt;Object = an instance of that blueprint, a real thing created based on the class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
Think of a Car class — it describes what a car is (color, model, year) and what it can do (drive, brake). When you create a Car object, say myCar, you’re making a specific car, like a red 2020 Toyota.&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;Car&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;color&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;year&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;drive&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;"The "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" car is driving."&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;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;Car&lt;/span&gt; &lt;span class="n"&gt;myCar&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;Car&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Creating an object&lt;/span&gt;
        &lt;span class="n"&gt;myCar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;myCar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;myCar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;drive&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Output: The Red car is driving.&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. What Are Constructors? Do We Have Destructors in Java Like C++?&lt;/strong&gt;&lt;br&gt;
Constructor: &lt;br&gt;
Think of it as a special method that builds your object. When you create an object, the constructor sets up initial values — like choosing the color and year of your car right when you build it.&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;Car&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;color&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;year&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor&lt;/span&gt;
    &lt;span class="nc"&gt;Car&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;c&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;y&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&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;Destructors?&lt;br&gt;
In C++, destructors clean up when an object is destroyed (like cleaning your room after playing). In Java, there are no destructors because Java has a garbage collector that automatically cleans up unused objects. So, you don’t have to worry about manually deleting objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. What Is static?&lt;/strong&gt;&lt;br&gt;
static is like a shared property or method that belongs to the class itself, not to any specific object.&lt;br&gt;
Example: Imagine a school where every student has a name (instance variable), but the school’s name is the same for all students (static variable).&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;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// each student has a name&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;school&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"ABC High School"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// shared by all students&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can access static stuff without creating an object:&lt;br&gt;
System.out.println(Student.school);  // Output: ABC High School&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. What Are Access Modifiers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Access modifiers control who can see or use your class members (variables, methods). Think of them as privacy levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;public: Everyone can see and use it — like a public park.&lt;/li&gt;
&lt;li&gt;private: Only the class itself can see it — like your diary.&lt;/li&gt;
&lt;li&gt;protected: The class and its subclasses (children) can see it — like family secrets.&lt;/li&gt;
&lt;li&gt;default (no modifier): Only classes in the same package can see it — like your neighborhood friends.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Example Scenarios &amp;amp; Scope of Access Modifiers&lt;/strong&gt;&lt;br&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%2Fmxs5m34eije4n3rum8a5.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%2Fmxs5m34eije4n3rum8a5.png" alt=" " width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. The 4 Pillars of OOP and How to Implement Them in Java&lt;/strong&gt;&lt;br&gt;
Encapsulation — Wrapping data and methods together, hiding details. Use private variables + public getters/setters.&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;Person&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&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="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&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="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setName&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;n&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;n&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;Inheritance — A class inherits properties/methods from another (like a child inheriting traits).&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;Animal&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;eat&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;"Eating"&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;Dog&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Animal&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;bark&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;"Barking"&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;Polymorphism — One interface, many forms. Methods can behave differently in subclasses.&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;Animal&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;sound&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;"Some sound"&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;Dog&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Animal&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;sound&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;"Bark"&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;Abstraction — Hiding complex details, showing only what’s necessary. Use abstract classes or interfaces.&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;Vehicle&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;move&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;Bike&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&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;move&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;"Bike is moving"&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;7. How Are Objects Instantiated in Memory?&lt;/strong&gt;&lt;br&gt;
When you create an object with new, Java allocates memory for it on the heap (the big memory area for objects). The reference (like a pointer) to that object lives on the stack.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Car myCar = new Car("Blue", 2021);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;myCar is a reference on the stack.&lt;/li&gt;
&lt;li&gt;The actual Car object is stored on the heap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;8. Can We Pass Objects as Arguments to Other Objects? How?&lt;/strong&gt;&lt;br&gt;
Objects can be passed as parameters to methods or constructors, enabling interaction between objects.&lt;br&gt;
Example: A Driver object can have a Car object passed to it.&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;Car&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;model&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Car&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;m&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&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;Driver&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;drive&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;car&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 a "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;model&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;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;Car&lt;/span&gt; &lt;span class="n"&gt;myCar&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;Car&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Tesla"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;Driver&lt;/span&gt; &lt;span class="n"&gt;d&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;Driver&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;drive&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myCar&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Output: Driving a Tesla&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;



</description>
      <category>beginners</category>
      <category>java</category>
      <category>object</category>
      <category>oop</category>
    </item>
  </channel>
</rss>
