<?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>Forem: Sanju Shaw</title>
    <description>The latest articles on Forem by Sanju Shaw (@deadpoolx7).</description>
    <link>https://forem.com/deadpoolx7</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1253536%2F7d4e61a2-e2b4-4c9c-8160-bdf25dfc1e00.jpg</url>
      <title>Forem: Sanju Shaw</title>
      <link>https://forem.com/deadpoolx7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/deadpoolx7"/>
    <language>en</language>
    <item>
      <title>You, Me, and Microservices</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Thu, 16 Apr 2026 16:17:01 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/you-me-and-microservices-2hpp</link>
      <guid>https://forem.com/deadpoolx7/you-me-and-microservices-2hpp</guid>
      <description>&lt;h2&gt;
  
  
  Let me tell you something.
&lt;/h2&gt;

&lt;p&gt;Every beginner learns how to build apps like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One backend&lt;br&gt;
One database&lt;br&gt;
Everything connected&lt;br&gt;
Everything… tightly packed&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Feels nice. Simple. Clean.&lt;/p&gt;

&lt;p&gt;Until one day…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;everything breaks.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Day Your App Betrays You
&lt;/h2&gt;

&lt;p&gt;Imagine this.&lt;/p&gt;

&lt;p&gt;You built a cool app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;login system&lt;/li&gt;
&lt;li&gt;payment system&lt;/li&gt;
&lt;li&gt;notifications&lt;/li&gt;
&lt;li&gt;search&lt;/li&gt;
&lt;li&gt;user profiles&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All inside one backend.&lt;/p&gt;

&lt;p&gt;Life is good.&lt;/p&gt;

&lt;p&gt;Then suddenly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Payment API slows down&lt;/li&gt;
&lt;li&gt;Entire app becomes slow&lt;/li&gt;
&lt;li&gt;One small bug → whole server crashes&lt;/li&gt;
&lt;li&gt;You try to fix one thing → 10 things break&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Welcome to the &lt;strong&gt;monolith nightmare&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is exactly why companies moved away from it.&lt;br&gt;
Because in monoliths:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  “one failure can bring the entire system down” 
&lt;/h2&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  So What Did Smart Engineers Do?
&lt;/h2&gt;

&lt;p&gt;They said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Why are we building ONE giant system…&lt;br&gt;
when we can build MANY small ones?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Boom.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microservices were born.&lt;/strong&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  What Even Is a Microservice?
&lt;/h2&gt;

&lt;p&gt;Simple.&lt;/p&gt;

&lt;p&gt;Instead of this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One giant backend doing EVERYTHING
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Auth Service
Payment Service
Notification Service
Search Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;runs independently&lt;/li&gt;
&lt;li&gt;deploys independently&lt;/li&gt;
&lt;li&gt;breaks independently 😌&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Technically speaking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Microservices are “small, independent services that communicate with each other” &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But forget the definition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Think of it like a team.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Think Like a Startup
&lt;/h2&gt;

&lt;p&gt;Imagine a startup.&lt;/p&gt;

&lt;p&gt;You don’t hire:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one guy who does everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You hire:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;backend dev&lt;/li&gt;
&lt;li&gt;frontend dev&lt;/li&gt;
&lt;li&gt;designer&lt;/li&gt;
&lt;li&gt;marketer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each person:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;does one job&lt;/li&gt;
&lt;li&gt;does it well&lt;/li&gt;
&lt;li&gt;works with others&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s microservices.&lt;/p&gt;




&lt;h2&gt;
  
  
  Now Let’s Get Real (Production Level Stuff)
&lt;/h2&gt;

&lt;p&gt;This is where most tutorials lie to you.&lt;/p&gt;

&lt;p&gt;They show:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Create 3 services, connect with REST API, done.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s NOT production.&lt;/p&gt;

&lt;p&gt;Real world looks like chaos.&lt;/p&gt;




&lt;h3&gt;
  
  
  Example: Amazon (Real System)
&lt;/h3&gt;

&lt;p&gt;When you click “Buy Now”:&lt;/p&gt;

&lt;p&gt;Behind the scenes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product Service → checks item&lt;/li&gt;
&lt;li&gt;Inventory Service → checks stock&lt;/li&gt;
&lt;li&gt;Payment Service → processes money&lt;/li&gt;
&lt;li&gt;Order Service → creates order&lt;/li&gt;
&lt;li&gt;Notification Service → sends email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these are **different services talking to each other.&lt;/p&gt;

&lt;p&gt;And guess what?&lt;/p&gt;

&lt;p&gt;If notification fails…&lt;/p&gt;

&lt;p&gt;Your order STILL goes through.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Truth Nobody Tells You
&lt;/h2&gt;

&lt;p&gt;Microservices are NOT easier.&lt;/p&gt;

&lt;p&gt;They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;harder to build&lt;/li&gt;
&lt;li&gt;harder to debug&lt;/li&gt;
&lt;li&gt;harder to manage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because now you’re dealing with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;network calls (not function calls)&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;failures between services&lt;/li&gt;
&lt;li&gt;distributed systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even the docs admit:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Microservices introduce “additional complexity… like latency and fault tolerance”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  So Why Do Big Companies Still Use It?
&lt;/h2&gt;

&lt;p&gt;Because at scale…&lt;/p&gt;

&lt;p&gt;Monolith = death ☠️&lt;/p&gt;

&lt;p&gt;Microservices = survival 🚀&lt;/p&gt;

&lt;p&gt;Companies like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Netflix&lt;/li&gt;
&lt;li&gt;Uber&lt;/li&gt;
&lt;li&gt;Amazon&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;use microservices because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;they can scale parts independently&lt;/li&gt;
&lt;li&gt;deploy features faster&lt;/li&gt;
&lt;li&gt;avoid full system crashes&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Actually Happens in Production
&lt;/h2&gt;

&lt;p&gt;Let’s simplify a real production flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User → API Gateway → Services → Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But inside?&lt;/p&gt;

&lt;p&gt;It’s more like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
  ↓
Load Balancer
  ↓
API Gateway
  ↓
Auth Service → Token
  ↓
Order Service → calls Inventory Service
                  ↓
              Payment Service
                  ↓
           Event Queue (Kafka)
                  ↓
         Notification Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah…&lt;/p&gt;

&lt;p&gt;It’s not pretty.&lt;/p&gt;

&lt;p&gt;But it’s powerful.&lt;/p&gt;




&lt;h2&gt;
  
  
  The One Concept That Will Make You Dangerous
&lt;/h2&gt;

&lt;p&gt;If you understand just this, you’re ahead of 90% devs:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Each microservice owns ONE business responsibility.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not “user service does everything”.&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auth handles login only&lt;/li&gt;
&lt;li&gt;Payment handles money only&lt;/li&gt;
&lt;li&gt;Inventory handles stock only&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;👉 &lt;strong&gt;Single Responsibility at system level&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Should YOU Use Microservices?
&lt;/h2&gt;

&lt;p&gt;Let’s be honest.&lt;/p&gt;

&lt;p&gt;If you are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;building a college project&lt;/li&gt;
&lt;li&gt;small startup&lt;/li&gt;
&lt;li&gt;solo dev&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Don’t.&lt;/p&gt;

&lt;p&gt;Start with monolith.&lt;/p&gt;

&lt;p&gt;Microservices are for when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;system grows&lt;/li&gt;
&lt;li&gt;team grows&lt;/li&gt;
&lt;li&gt;traffic grows&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Microservices are not about code.&lt;/p&gt;

&lt;p&gt;They are about &lt;strong&gt;how you think about systems&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;From:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Let me build this feature”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“How will this behave when 1 million users hit it?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That shift…&lt;/p&gt;

&lt;p&gt;That’s what separates:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;developers → engineers&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>microservices</category>
      <category>backend</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>How to implement Pagination in Spring-boot project?</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Sat, 15 Nov 2025 16:26:55 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/how-to-implement-pagination-in-spring-boot-project-4p4</link>
      <guid>https://forem.com/deadpoolx7/how-to-implement-pagination-in-spring-boot-project-4p4</guid>
      <description>&lt;p&gt;Before beginning, let’s understand what pagination actually is.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Pagination&lt;/code&gt; simply means breaking a huge dataset into smaller chunks or pages. This is exactly what you see on e-commerce websites when products load page by page, or when you scroll through Google search results — you never get all the data at once.&lt;/p&gt;

&lt;p&gt;It's useful because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You save bandwidth.&lt;/li&gt;
&lt;li&gt;Backend responds faster&lt;/li&gt;
&lt;li&gt;UI becomes smoother.&lt;/li&gt;
&lt;li&gt;Database queries remain optimized&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to set-up pagination
&lt;/h2&gt;

&lt;p&gt;Suppose we have an API like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/api/books?query&lt;span class="o"&gt;=&lt;/span&gt;adventure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can easily configure the backend to limit the number of items returned.&lt;br&gt;
Spring Data JPA already gives built-in support for pagination using Pageable.&lt;/p&gt;

&lt;p&gt;We can also let the client decide how many results they want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/api/books?query&lt;span class="o"&gt;=&lt;/span&gt;adventure&amp;amp;page&lt;span class="o"&gt;=&lt;/span&gt;0&amp;amp;size&lt;span class="o"&gt;=&lt;/span&gt;20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;page&lt;/code&gt; -&amp;gt; which page number(0-based index)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;size&lt;/code&gt; -&amp;gt; how many items per page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's implement this properly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Coding time 🧑‍💻
&lt;/h2&gt;

&lt;p&gt;We are using &lt;strong&gt;Spring Boot + MySQL + Spring Data JPA.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Controller Layer&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;@RestController
@RequestMapping&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/books"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
public class BookController &lt;span class="o"&gt;{&lt;/span&gt;

    @Autowired
    private BookService bookService&lt;span class="p"&gt;;&lt;/span&gt;

    @GetMapping
    public Page&amp;lt;Book&amp;gt; getBooks&lt;span class="o"&gt;(&lt;/span&gt;
            @RequestParam&lt;span class="o"&gt;(&lt;/span&gt;defaultValue &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"adventure"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; String query,
            @RequestParam&lt;span class="o"&gt;(&lt;/span&gt;defaultValue &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; int page,
            @RequestParam&lt;span class="o"&gt;(&lt;/span&gt;defaultValue &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; int size&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;bookService.getBooks&lt;span class="o"&gt;(&lt;/span&gt;query, page, size&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&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;ul&gt;
&lt;li&gt;we use Spring's &lt;code&gt;Page&lt;/code&gt; class&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;page&lt;/code&gt; &amp;amp; &lt;code&gt;size&lt;/code&gt; have default values.&lt;/li&gt;
&lt;li&gt;Output automatically includes : totalElements, totalPages, current page number, size, and you actual data list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Service Layer(Business Logic):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;@Service
public class BookService &lt;span class="o"&gt;{&lt;/span&gt;

    @Autowired
    private BookRepository bookRepository&lt;span class="p"&gt;;&lt;/span&gt;

    public Page&amp;lt;Book&amp;gt; getBooks&lt;span class="o"&gt;(&lt;/span&gt;String query, int page, int size&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        Pageable pageable &lt;span class="o"&gt;=&lt;/span&gt; PageRequest.of&lt;span class="o"&gt;(&lt;/span&gt;page, size&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return &lt;/span&gt;bookRepository.findByTitleContainingIgnoreCase&lt;span class="o"&gt;(&lt;/span&gt;query, pageable&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&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;/p&gt;

&lt;ul&gt;
&lt;li&gt;`PageRequest.of(page, size) creates the pagination configuration.&lt;/li&gt;
&lt;li&gt;Repository method automatically handles pagination.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Repository Layer:&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%2Fvvq7wag1rdtmefv28lmk.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%2Fvvq7wag1rdtmefv28lmk.png" alt=" " width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the beauty of Spring Data JPA - no SQL written manually.&lt;br&gt;
It handles :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LIMIT&lt;/li&gt;
&lt;li&gt;OFFSET&lt;/li&gt;
&lt;li&gt;Filtering&lt;/li&gt;
&lt;li&gt;Sorting 
All under the hood.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;&lt;strong&gt;want to sort the results??&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
/api/books?page=0&amp;amp;size=10&amp;amp;sort=price,desc&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change your controller parameter:&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%2F44j51kg0nedcqmhec9cn.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%2F44j51kg0nedcqmhec9cn.png" alt=" " width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Result
&lt;/h2&gt;

&lt;p&gt;If you call:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
GET /api/books?query=adventure&amp;amp;page=0&amp;amp;size=5&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Response be like:&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%2Fkwl0vfe24113schhuaza.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%2Fkwl0vfe24113schhuaza.png" alt=" " width="800" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is how pagination works smoothly in Spring Boot.&lt;/p&gt;

&lt;p&gt;Follow me  for more Java oriented and system design content. Thanks for reading!&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>pagination</category>
      <category>backend</category>
      <category>java</category>
    </item>
    <item>
      <title>How to build a scalable backend , step-by-step</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Sun, 26 Oct 2025 10:58:38 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/how-to-build-a-scalable-backend-step-by-step-4ngk</link>
      <guid>https://forem.com/deadpoolx7/how-to-build-a-scalable-backend-step-by-step-4ngk</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;TL;DR&lt;/em&gt;&lt;/strong&gt;: Start with clear goals and metrics, design small stateless services, move heavy work off the critical path with asynchronous messaging, cache aggressively, scale horizontally, automate everything, and observe continuously.&lt;br&gt;
&lt;br&gt; Follow proven principles (e.g. the Twelve-Factor approach) and pick patterns like CQRS/event sourcing only when the complexity pays off.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why “scalable” and what that really means
&lt;/h2&gt;

&lt;p&gt;“Scalable” doesn’t mean “can handle infinite traffic.”&lt;/p&gt;

&lt;p&gt;It means your system can meet future load and change requirements without a full redesign: add machines (horizontal scaling), add automation (CI/CD, infra as code), and keep operations cheap and predictable.&lt;/p&gt;

&lt;p&gt;Before coding, pick measurable goals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Target traffic:&lt;/strong&gt; requests/sec, concurrent users, or data - growth per month.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SLOs&lt;/strong&gt;: p99 latency ≤ X ms, availability 99.9% (SLA), error budget.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost budget:&lt;/strong&gt; expected monthly infra spend.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Measure these — they will drive all tradeoffs later.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1 - Start with good principles(do this first)
&lt;/h2&gt;

&lt;p&gt;Treat services as processes, externalize config, and make deployments reproducible.&lt;/p&gt;

&lt;p&gt;The Twelve-Factor App is a concise, practical baseline for cloud-native, scalable apps: one codebase, config in env, processes are stateless, backing services treated as attached resources, logs as event streams, etc. &lt;br&gt;
These principles make horizontal scaling predictable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick checklist&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single repo per service(or mono-repo with clear boundaries).&lt;/li&gt;
&lt;li&gt;Config in environment variables or a config service.&lt;/li&gt;
&lt;li&gt;Build -&amp;gt; release -&amp;gt; run pipeline(CI/CD).&lt;/li&gt;
&lt;li&gt;Processes must be stateless whenever possible.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Step 2 — Define bounded contexts and verticals (domain decomposition)
&lt;/h2&gt;

&lt;p&gt;Split complexity by business domain (users, orders, billing). Each domain becomes a candidate microservice or logical module. &lt;br&gt;
This reduces blast radius and lets you scale only hot domains.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;api-gateway
  ├─ auth-service
  ├─ orders-service
  ├─ inventory-service
  └─ billing-service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3 — Make services stateless and externalize state
&lt;/h2&gt;

&lt;p&gt;Stateless processes are the easiest to scale: add more instances behind a load balancer.&lt;/p&gt;

&lt;p&gt;Where to keep state:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Relational/NoSQL DB for canonical data.&lt;/li&gt;
&lt;li&gt;Cache(redis) for hot reads.&lt;/li&gt;
&lt;li&gt;Object-storage(S3) for blobs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Twelve-Factor explicitly recommends processes be stateless and backing services treated as attached resources — design with that in mind.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4 — Put slow work off the critical path (async messaging)
&lt;/h2&gt;

&lt;p&gt;Synchronous calls couple latency and availability. Use message queues or event buses for background processing (email sending, heavy reports, third-party API retries).&lt;/p&gt;

&lt;p&gt;Common patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queue-based workers: produce to queue (RabbitMQ/SQS/Kafka), workers consume and process.&lt;/li&gt;
&lt;li&gt;Event-driven: publish events to an event bus; multiple subscribers react. For long-lived state or audit trails, consider event sourcing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When to use Event Sourcing / CQRS: useful for systems where auditability, replay-ability, or complex read models matter (financial systems, order histories). They add complexity — evaluate tradeoffs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5 — Caching: reduce load and latency
&lt;/h2&gt;

&lt;p&gt;Cache at multiple levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client&lt;/strong&gt; : HTTP cache headers, ETag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge/CDN&lt;/strong&gt; : cache static assets and cacheable api responses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App-level&lt;/strong&gt; : in-memory caches for repeated computations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed cache&lt;/strong&gt; : Redis for shared hot data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Design cache invalidation carefully — “cache invalidation” is famously one of the two hardest problems in CS. Prefer short TTLs for dynamic data and event-based invalidation when possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6 — Database scaling: replicas, partitioning, and polyglot storage
&lt;/h2&gt;

&lt;p&gt;Start simple (single primary + read replicas). When read traffic overwhelms, add replicas; when writes are the bottleneck, consider sharding/partitioning.&lt;/p&gt;

&lt;p&gt;Options :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read replicas for read-heavy workloads.&lt;/li&gt;
&lt;li&gt;Sharding for very large datasets or high write throughput.&lt;/li&gt;
&lt;li&gt;Choose the DB that fits access pattern: relational for transactions, wide-column or document DBs for flexible schemas, and time-series for metrics.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 7 — Load balancing and autoscaling
&lt;/h2&gt;

&lt;p&gt;Exterior layer :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API Gateway / Load balancer(NGINX) + routing, retries, rate limiting.&lt;/li&gt;
&lt;li&gt;Horizontal pod autoscaler(k8s) or cloud groups for compute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Autoscaling rules should be driven by business metrics (requests/sec, queue length, CPU) and respect warm-up time for new instances.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 8 — Deploy with containers and orchestration
&lt;/h2&gt;

&lt;p&gt;Containerize with Docker, deploy to Kubernetes or managed container platforms.&lt;br&gt;
Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;consistent runtime&lt;/li&gt;
&lt;li&gt;resource isolation&lt;/li&gt;
&lt;li&gt;standard deployment patterns(rolling updates, rolling restarts).
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM node:18-alpine
WORKDIR /app
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm ci &lt;span class="nt"&gt;--only&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
COPY &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
CMD &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"server.js"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;k8s snippet (deployment + HPA)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata: &lt;span class="o"&gt;{&lt;/span&gt; name: orders-service &lt;span class="o"&gt;}&lt;/span&gt;
spec:
  replicas: 2
  template:
    spec:
      containers:
      - name: orders
        image: your-registry/orders:1.0
        resources:
          requests: &lt;span class="o"&gt;{&lt;/span&gt; cpu: &lt;span class="s2"&gt;"100m"&lt;/span&gt;, memory: &lt;span class="s2"&gt;"128Mi"&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;---&lt;/span&gt;
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata: &lt;span class="o"&gt;{&lt;/span&gt; name: orders-hpa &lt;span class="o"&gt;}&lt;/span&gt;
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: orders-service
  minReplicas: 2
  maxReplicas: 20
  metrics:
  - &lt;span class="nb"&gt;type&lt;/span&gt;: Resource
    resource:
      name: cpu
      target: &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;: Utilization, averageUtilization: 60 &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Autoscaling in k8s is a standard pattern — use sensible metrics and test.)&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 9 — Observability: logs, metrics, tracing
&lt;/h2&gt;

&lt;p&gt;_ You can't fix what you can't see._ Implement :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Centralized logs (JSON logs -&amp;gt; ELK/ Loki).&lt;/li&gt;
&lt;li&gt;Metrics (Prometheus + Grafana).&lt;/li&gt;
&lt;li&gt;Distributed tracing(OpenTelemetry, Jaeger).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Correlate traces with logs to find latency hotspots and understand end-to-end flows.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 10 — Reliability practices: retries, circuit breakers, and bulkheads
&lt;/h2&gt;

&lt;p&gt;Design services to fail gracefully :; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retries with exponential backoff.&lt;/li&gt;
&lt;li&gt;Circuit breakers to abvoid cascading failures.&lt;/li&gt;
&lt;li&gt;Bulkheads to isolate resource pools(e.g., separate thread pools or queues per integration).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These patterns help maintain partial availability during degraded conditions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 11 — Security and operational concerns
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use IAM and least privilege for cloud resources.&lt;/li&gt;
&lt;li&gt;Secure secrets (Vault, cloud KMS).&lt;/li&gt;
&lt;li&gt;harden APIs with rate limits and auth(JWT/OAuth).&lt;/li&gt;
&lt;li&gt;Plan backups, DR strategies, and recovery drills.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 12 — Test for scale (not just correctness)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Load testing(k6, wrk).&lt;/li&gt;
&lt;li&gt;Soak test(long running) to expose memory leaks.&lt;/li&gt;
&lt;li&gt;Chaos engineering (start small - kill a pod, simulate network partition).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Seeing how the system behaves under stress reveals real bottlenecks and bad assumptions.&lt;/p&gt;




&lt;h2&gt;
  
  
  When to adopt advanced patterns (and when not to)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CQRS/Event Sourcing:&lt;/strong&gt; adopt if you need auditability, replayability, or independent read models. They’re powerful but add complexity — only for high-value use-cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microservices&lt;/strong&gt;: useful for larger teams and independent scaling. For small teams or simple apps, a well-structured monolith (modular codebase) often beats premature microservices.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  A simple growth roadmap....
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;MVP:&lt;/strong&gt; single service, RDS/managed db, simple caching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale reads:&lt;/strong&gt; add CDN and DB read replicas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decouple:&lt;/strong&gt; add queues for background work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split:&lt;/strong&gt; extract hot domains into separate services.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Optimize:&lt;/strong&gt; add autoscaling, observability, and chaos tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evolve:&lt;/strong&gt; use CQRS/event sourcing only if business justify it.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>backend</category>
      <category>backenddevelopment</category>
      <category>systemdesign</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Building a Web Scraper in 1 Java File☕</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Mon, 04 Aug 2025 15:27:23 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/building-a-web-scraper-in-1-java-file-447g</link>
      <guid>https://forem.com/deadpoolx7/building-a-web-scraper-in-1-java-file-447g</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I was deep in the Oracle &lt;code&gt;java.net&lt;/code&gt; docs, coffee in hand, when the idea hit me: &lt;em&gt;build a minimalist web scraper in a single file—just to see if I could :)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  ✨ Introduction
&lt;/h2&gt;

&lt;p&gt;Ever wondered how search engines crawl web pages?&lt;br&gt;
Or how job sites gather listings from other websites?&lt;/p&gt;

&lt;p&gt;That’s all thanks to &lt;strong&gt;web scraping&lt;/strong&gt;. In this post, I’ll show you how I built a simple web scraper in pure Java, without any libraries, all in a single file.&lt;/p&gt;

&lt;p&gt;Even if you’re new to Java’s networking or regex features, don’t worry—I’ll walk you through it all.&lt;/p&gt;
&lt;h2&gt;
  
  
  📌What you'll learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to take a website URL from the user&lt;/li&gt;
&lt;li&gt;How to fetch its HTML using &lt;code&gt;HttpURLConnection&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;How to extract the &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; and all &lt;code&gt;&amp;lt;a href="..."&amp;gt;&lt;/code&gt; links using regex&lt;/li&gt;
&lt;li&gt;How to handle common errors gracefully&lt;/li&gt;
&lt;li&gt;Why this is a powerful starting point for automating the web&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Let's dive in 🤿
&lt;/h2&gt;

&lt;p&gt;Create a file &lt;code&gt;WebScraper.java&lt;/code&gt;&lt;em&gt;(or name anything you desire)&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;public class WebScraper &lt;span class="o"&gt;{&lt;/span&gt;
 public static void main&lt;span class="o"&gt;(&lt;/span&gt;String[] args&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;args.length &amp;lt; 1&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            System.err.println&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"❌ Please provide a URL as the first argument."&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        String inputUrl &lt;span class="o"&gt;=&lt;/span&gt; args[0]&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this code snippet does is to take provided url from CLI and if not found any URL then throw an error and quit running.&lt;/p&gt;

&lt;p&gt;Next part :&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;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="no"&gt;URI&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;URI&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputUrl&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
            &lt;span class="no"&gt;URL&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toURL&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;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fetchHTML&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&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;err&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;" Failed to fetch content or empty page."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="o"&gt;;&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;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;extractTitle&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&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;" Page Title: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"N/A"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

            &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;extractLinks&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&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;"\n Links found:"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&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 &amp;lt;a&amp;gt; tags found."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;forEach&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="n"&gt;println&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="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&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;err&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;" Error: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMessage&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 portion creates URL from provided string in CLI with the help of URI package as direct use of URL has been deprecated from Java 11+.&lt;/p&gt;

&lt;p&gt;Next we're fetching HTML from a function, thereafter fetching associated links in the site and printing them gracefully.&lt;/p&gt;

&lt;p&gt;Here's &lt;code&gt;fetchHTML&lt;/code&gt; fucntion:&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;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;fetchHTML&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;URL&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;html&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;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;HttpURLConnection&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpURLConnection&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;openConnection&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setRequestMethod&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"GET"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BufferedReader&lt;/span&gt; &lt;span class="n"&gt;reader&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;BufferedReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;InputStreamReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getInputStream&lt;/span&gt;&lt;span class="o"&gt;())))&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;line&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;readLine&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&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;err&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;"❌ Failed to fetch HTML: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMessage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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;First off all we're opening a connection using &lt;code&gt;openConnection()&lt;/code&gt; method in URL and type-casting the return into &lt;code&gt;HttpURLConnection&lt;/code&gt; type for dispatching a &lt;strong&gt;GET&lt;/strong&gt; request to access the site.&lt;br&gt;
Later creating an InputStream using BufferedReader and storing entire &lt;code&gt;HTML&lt;/code&gt; content in our string builder one at a time. &lt;em&gt;Go ahead print this string-builder and see how it looks.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Now, we've 2 more functions one for extracting title from html and extracting links.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;-&lt;strong&gt;&lt;em&gt;extractTitle(html):&lt;/em&gt;&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;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;extractTitle&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;html&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;title&amp;gt;(.*?)&amp;lt;/title&amp;gt;"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;CASE_INSENSITIVE&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;DOTALL&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;Matcher&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&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;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&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;Why not you tell me in the comments how this pattern matching works?&lt;br&gt;
Let's see how much you are following😀&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;extractLinks(html):&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;extractLinks&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;html&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;links&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;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;a\\s+(?:[^&amp;gt;]*?\\s+)?href=[\"'](.*?)[\"']"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;CASE_INSENSITIVE&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;Matcher&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="o"&gt;())&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;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;link&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;links&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;Matching &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag pattern and storing them to a list.&lt;/p&gt;




&lt;h2&gt;
  
  
  Here's the full code :
&lt;/h2&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;java.io.BufferedReader&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.io.InputStreamReader&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.net.HttpURLConnection&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.net.URI&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.net.URL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.regex.Matcher&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.regex.Pattern&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.ArrayList&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.List&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;WebScrapper&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="k"&gt;if&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="na"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&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;err&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;"❌ Please provide a URL as the first argument."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="o"&gt;;&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;inputUrl&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="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="no"&gt;URI&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;URI&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputUrl&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
            &lt;span class="no"&gt;URL&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toURL&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;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fetchHTML&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&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;err&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;" Failed to fetch content or empty page."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="o"&gt;;&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;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;extractTitle&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&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;" Page Title: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"N/A"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

            &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;extractLinks&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&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;"\n Links found:"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&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 &amp;lt;a&amp;gt; tags found."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;forEach&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="n"&gt;println&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="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&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;err&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;" Error: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMessage&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;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;fetchHTML&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;URL&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;html&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;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;HttpURLConnection&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpURLConnection&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;openConnection&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setRequestMethod&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"GET"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BufferedReader&lt;/span&gt; &lt;span class="n"&gt;reader&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;BufferedReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;InputStreamReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getInputStream&lt;/span&gt;&lt;span class="o"&gt;())))&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;line&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
                &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;readLine&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&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;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;html&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s"&gt;"\n"&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;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&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;err&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;"❌ Failed to fetch HTML: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMessage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;extractTitle&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;html&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;title&amp;gt;(.*?)&amp;lt;/title&amp;gt;"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;CASE_INSENSITIVE&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;DOTALL&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;Matcher&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&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;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;extractLinks&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;html&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;links&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;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;a\\s+(?:[^&amp;gt;]*?\\s+)?href=[\"'](.*?)[\"']"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;CASE_INSENSITIVE&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;Matcher&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="o"&gt;())&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;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;matcher&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;link&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;links&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;ul&gt;
&lt;li&gt;Compile and Run the file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;javac&lt;/span&gt; &lt;span class="nc"&gt;WebScraper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;java&lt;/span&gt;

&lt;span class="n"&gt;java&lt;/span&gt; &lt;span class="nc"&gt;WebScraper&lt;/span&gt; &lt;span class="nl"&gt;https:&lt;/span&gt;&lt;span class="c1"&gt;//github.com  &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Output:
&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%2Fmfg8df6l1xj9d9knksir.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%2Fmfg8df6l1xj9d9knksir.png" alt="Output Screenshot" width="800" height="481"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🙌 Final Thoughts:
&lt;/h2&gt;

&lt;p&gt;Yes, I know this is a simple scraper. Several developments can be made integration of tools such as JSoup can be done and much more.&lt;br&gt;&lt;br&gt;
But, This small scraper gave me a deep understanding of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How Java connects to the web&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to read and process HTML&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How regex can extract meaningful data&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found this useful, drop a 💬 or ❤️.&lt;br&gt;
And if you want me to turn this into a downloadable CLI tool, let me know in the comments!&lt;/p&gt;

&lt;h2&gt;
  
  
  ✨ Connect With Me
&lt;/h2&gt;

&lt;p&gt;You can follow me here on &lt;code&gt;Dev.to&lt;/code&gt; or connect with me on GitHub for more hands-on Java + tooling content!&lt;/p&gt;

</description>
      <category>java</category>
      <category>webscraping</category>
      <category>backend</category>
      <category>programming</category>
    </item>
    <item>
      <title>☁️ AWS Free Tier – Your Survival Guide to Building on the Cloud</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Tue, 29 Jul 2025 12:04:47 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/aws-free-tier-your-survival-guide-to-building-on-the-cloud-52c1</link>
      <guid>https://forem.com/deadpoolx7/aws-free-tier-your-survival-guide-to-building-on-the-cloud-52c1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Slurping coffee ☕&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;AWS is like that intimidating gym in your neighborhood — full of shiny machines, you don’t know where to start, and you’re scared you might pull something (in this case, your wallet).&lt;/p&gt;

&lt;p&gt;If you’re a beginner, the &lt;strong&gt;AWS Free Tier&lt;/strong&gt; is your entry ticket. But here’s the thing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It’s &lt;strong&gt;not&lt;/strong&gt; a magic “everything is free forever” card.&lt;/li&gt;
&lt;li&gt;It’s &lt;strong&gt;not&lt;/strong&gt; idiot-proof (you can still launch a $200/month server by clicking the wrong dropdown).&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;is&lt;/strong&gt; a golden sandbox if you know what you’re doing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This isn’t a “hey, just sign up for AWS and it’ll be fun!” post. This is the &lt;strong&gt;comprehensive guide&lt;/strong&gt; that tells you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what’s actually free,&lt;/li&gt;
&lt;li&gt;how not to get billed,&lt;/li&gt;
&lt;li&gt;what you can realistically build,&lt;/li&gt;
&lt;li&gt;and why you should even care.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Coffee ready? Let’s go.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗 What the Heck &lt;em&gt;Is&lt;/em&gt; AWS Free Tier?
&lt;/h2&gt;

&lt;p&gt;The AWS Free Tier is basically Amazon saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Here, try out our services before you decide whether you want to commit. Oh, and if you mess up — that’s on you.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It comes in &lt;strong&gt;3 categories&lt;/strong&gt; (don’t mix them up):&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ 1. Always Free
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Stays free. Forever.&lt;/li&gt;
&lt;li&gt;Stuff like &lt;strong&gt;1M Lambda requests/month&lt;/strong&gt;, &lt;strong&gt;25GB DynamoDB storage&lt;/strong&gt;, &lt;strong&gt;1M API Gateway calls&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Perfect for &lt;strong&gt;tiny side projects&lt;/strong&gt; and “learning mode” work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📅 2. 12-Month Free
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Free for your &lt;strong&gt;first year&lt;/strong&gt; after account creation.&lt;/li&gt;
&lt;li&gt;Includes big-ticket items like &lt;strong&gt;750 hours/month of EC2 t2.micro/t3.micro&lt;/strong&gt; and &lt;strong&gt;750 hours of RDS&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Important:&lt;/strong&gt; Month 13 comes. The bill comes with it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⏳ 3. Short-Term Trials
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;“Try SageMaker for 2 months” or “Kendra for 30 days.”&lt;/li&gt;
&lt;li&gt;Useful for testing, easy to forget to turn off.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Check out their official docs:&lt;/strong&gt;&lt;/em&gt; &lt;a href="https://aws.amazon.com/free/" rel="noopener noreferrer"&gt;AWS Free Tier official page&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🖥 What’s Actually Worth Using (and What You’ll Break Stuff With First)
&lt;/h2&gt;

&lt;p&gt;Let’s cut through the AWS glossary soup. Here’s the &lt;strong&gt;Free Tier starter pack&lt;/strong&gt; and &lt;strong&gt;what you can do with it&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🖥 &lt;strong&gt;EC2 (Elastic Compute Cloud)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;750 hours/month&lt;/strong&gt; for a &lt;code&gt;t2.micro&lt;/code&gt; or &lt;code&gt;t3.micro&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Think of it as your first “tiny Linux box in the cloud.”&lt;/li&gt;
&lt;li&gt;Build: a portfolio site, a simple API, or a WordPress blog.&lt;/li&gt;
&lt;li&gt;⚠️ &lt;strong&gt;Danger Zone:&lt;/strong&gt; &lt;strong&gt;Don’t pick “m5.4xlarge” because it “sounds faster.”&lt;/strong&gt; &lt;em&gt;That’s a Lamborghini rental, not a free bicycle.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;📦 &lt;strong&gt;S3 (Simple Storage Service)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;5GB Standard Storage&lt;/strong&gt;, thousands of requests.&lt;/li&gt;
&lt;li&gt;Build: host a &lt;strong&gt;static website&lt;/strong&gt;, backup project files, store memes.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🎯 CLI Example – Create an S3 bucket:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  aws s3 mb s3://my-free-tier-bucket
  aws s3 &lt;span class="nb"&gt;cp &lt;/span&gt;index.html s3://my-free-tier-bucket
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(For those who are using aws CLI can store media in S3 by running the command above)&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🗄 &lt;strong&gt;RDS (Relational Database Service)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;750 hours&lt;/strong&gt; for MySQL/PostgreSQL t2.micro.&lt;/li&gt;
&lt;li&gt;Build: a managed DB for your app (without “sudo apt install mysql” headaches).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;☁️ &lt;strong&gt;Lambda&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1M free requests/month&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Build: a Discord bot, a webhook, or a cron job that runs “every morning at 7 AM” without leaving your PC on.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;🌐 &lt;strong&gt;CloudFront&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1TB/month&lt;/strong&gt; free data transfer.&lt;/li&gt;
&lt;li&gt;Build: a CDN for your site → faster load times (and bragging rights).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚠️ The Dark Side of Free Tier:
&lt;/h2&gt;

&lt;p&gt;AWS won’t &lt;em&gt;stop&lt;/em&gt; you from making expensive mistakes. Here’s what beginners learn the hard way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;⚡ The “free” instance trap&lt;/strong&gt; → Free tier covers &lt;code&gt;t2.micro&lt;/code&gt; and &lt;code&gt;t3.micro&lt;/code&gt;. Click anything bigger → &lt;strong&gt;cha-ching.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;📤 Data Transfer Gotchas&lt;/strong&gt; → Inbound traffic = usually free. Outbound = not always. Your side project going viral? That might cost you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;🗑 Zombie Resources&lt;/strong&gt; → You stop using an EC2 instance but forget to &lt;strong&gt;terminate&lt;/strong&gt; it? AWS doesn’t “assume you’re done.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;🔔 No Billing Alerts&lt;/strong&gt; → If you don’t set them, you’ll only find out about charges when your card statement hits.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;One can set up a billing alarm using AWS CloudWatch.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 *&lt;em&gt;🧠 Some AWS wisdom *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;☑ &lt;strong&gt;“Stopped” ≠ “Deleted”&lt;/strong&gt; – Stopping EC2 doesn’t stop charges for storage. TERMINATE.&lt;/p&gt;

&lt;p&gt;☑ &lt;strong&gt;Regions matter&lt;/strong&gt; – Some Free Tier resources are “per region,” some are global. Don’t scatter them everywhere.&lt;/p&gt;

&lt;p&gt;☑ &lt;strong&gt;IAM users &amp;gt; root account&lt;/strong&gt; – Never develop with the root account. Use IAM users.&lt;/p&gt;

&lt;p&gt;☑ &lt;strong&gt;Billing dashboard is your friend&lt;/strong&gt; – Check it like you check your phone battery.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 So… What Can You Actually Build for Free?
&lt;/h2&gt;

&lt;p&gt;Here’s where the magic happens. Real beginner-friendly &lt;strong&gt;projects&lt;/strong&gt; that don’t trigger billing nightmares:&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Host Your Portfolio or Blog&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;EC2 (server) + S3 (assets) + CloudFront (CDN).&lt;/li&gt;
&lt;li&gt;Tell recruiters: “Yeah, my site runs on AWS infrastructure.” Boom 💥.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Create a Serverless REST API&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lambda + API Gateway + DynamoDB.&lt;/li&gt;
&lt;li&gt;No server management, no 24/7 EC2 bill.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Build a Discord/Telegram Bot&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lambda runs only when triggered.&lt;/li&gt;
&lt;li&gt;Free Tier = no “always-on server” costs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Experiment with CI/CD&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Play with AWS &lt;code&gt;CodePipeline&lt;/code&gt; + &lt;code&gt;CodeBuild&lt;/code&gt;, or even Terraform → Learn DevOps for free.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Run a Small Database&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RDS for MySQL/Postgres → Learn DB management without local setup pain.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠 Tips for Staying Sane on Free Tier
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;☑ Always check the region.&lt;/strong&gt; Free Tier applies everywhere, but pricing differs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;☑ Delete resources.&lt;/strong&gt; EC2 stopped ≠ EC2 deleted. Delete. Terminate. Burn the evidence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;☑ Use the AWS Pricing Calculator.&lt;/strong&gt; Before you YOLO deploy something, sanity-check it: &lt;a href="https://calculator.aws/" rel="noopener noreferrer"&gt;calculator.aws&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;☑ Stay in the docs.&lt;/strong&gt; Not glamorous, but &lt;a href="https://aws.amazon.com/free/" rel="noopener noreferrer"&gt;AWS Free Tier docs&lt;/a&gt; will save you🍀.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ☕ Final Sip
&lt;/h2&gt;

&lt;p&gt;The AWS Free Tier isn’t just a “free hosting coupon.” It’s your &lt;strong&gt;cloud playground&lt;/strong&gt;. You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn how real-world infrastructure works.&lt;/li&gt;
&lt;li&gt;Build a side project or even an MVP for $0.&lt;/li&gt;
&lt;li&gt;Impress interviewers (“Oh yeah, I deployed that API on AWS Lambda”).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But it’s also &lt;strong&gt;not a toy&lt;/strong&gt; — treat it recklessly and you’ll learn the fastest DevOps lesson of all: &lt;strong&gt;cloud billing is scarier than any production bug.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 So go ahead. Spin up that &lt;code&gt;t2.micro&lt;/code&gt;, deploy your first Lambda, host your blog.&lt;br&gt;
And remember: &lt;strong&gt;delete your experiments&lt;/strong&gt; before AWS deletes your bank balance.&lt;/p&gt;




&lt;p&gt;📌 &lt;strong&gt;P.S.&lt;/strong&gt; – This was your map of the AWS Free Tier jungle. &lt;br&gt;
&lt;strong&gt;Next up:&lt;/strong&gt; we’ll dive into &lt;strong&gt;real beginner-friendly projects you can build on AWS for $0&lt;/strong&gt; — from serverless APIs to personal dashboards. Stay tuned with coffee🍵.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>cloudcomputing</category>
      <category>webdev</category>
    </item>
    <item>
      <title>🚀 Java Streams Explained Like You’re Five (But With Pro-Level Depth)</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Sat, 12 Jul 2025 07:47:29 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/java-streams-explained-like-youre-five-but-with-pro-level-depth-37an</link>
      <guid>https://forem.com/deadpoolx7/java-streams-explained-like-youre-five-but-with-pro-level-depth-37an</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;“Stream API is not just syntactic sugar. It's a paradigm shift.”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Whether you're new to Java or already knee-deep in lambda expressions, you've probably heard of &lt;strong&gt;Streams&lt;/strong&gt;—Java’s way of &lt;em&gt;making code beautiful, declarative, and parallel-friendly&lt;/em&gt;. Introduced in Java 8, which I would quote it as &lt;em&gt;"Revolutionary"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But what exactly are streams? &lt;br&gt;
Are they just fancy loops? &lt;br&gt;
Are they fast? &lt;br&gt;
Are they magic?&lt;/p&gt;

&lt;p&gt;Grab a cup of coffee ☕—we’re about to &lt;strong&gt;crack Java Streams wide open&lt;/strong&gt; in a way that anyone (yes, even beginners) can understand.&lt;/p&gt;


&lt;h2&gt;
  
  
  🏁 Part 1: What Are Java Streams?
&lt;/h2&gt;

&lt;p&gt;At its core, a &lt;strong&gt;Stream&lt;/strong&gt; is a sequence of data that you can operate on &lt;em&gt;in a functional style&lt;/em&gt;—map, filter, reduce, etc.—&lt;strong&gt;without mutating the original data&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  🆚 Traditional vs Stream
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's say you want to add people with &amp;gt; 18 age to names list:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Traditional 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="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;names&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;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAge&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getName&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;With Streams:&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;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAge&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;Person:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;collect&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Collectors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toList&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how: &lt;br&gt;
&lt;em&gt;✅Cleaner&lt;/em&gt;&lt;br&gt;
&lt;em&gt;✅Declarative&lt;/em&gt;&lt;br&gt;
&lt;em&gt;✅Chainable&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  🔄 Part 2: How Streams Work – Under the Hood
&lt;/h2&gt;

&lt;p&gt;Streams are not collections. They don’t store data, they carry data from source to destination through a pipeline of operations.&lt;/p&gt;

&lt;p&gt;🔗 Stream Pipeline&lt;br&gt;
Every stream has 3 steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt;&lt;br&gt;
Like Collection.stream(), Files.lines(), IntStream.range(), etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Intermediate Operations (lazy)&lt;/strong&gt;&lt;br&gt;
Like filter(), map(), sorted() – they return a new stream.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Terminal Operation (eager)&lt;/strong&gt;&lt;br&gt;
Like collect(), forEach(), reduce() – triggers the pipeline.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Until a terminal operation is called, nothing happens.&lt;br&gt;
This is lazy evaluation.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  🧠 Stream Internals – Building a Lazy Machine
&lt;/h2&gt;

&lt;p&gt;Here’s a simplified internal flow:&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;people&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAge&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// creates a FilterOp&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;         &lt;span class="c1"&gt;// creates a MapOp&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;collect&lt;/span&gt;&lt;span class="o"&gt;(...)&lt;/span&gt;                  &lt;span class="c1"&gt;// traverses and pulls one element at a time&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each intermediate op builds a pipeline stage. When terminal operation starts, it pulls one element through the chain.&lt;/p&gt;

&lt;p&gt;Think of it like a conveyor belt, not a loop.&lt;/p&gt;




&lt;h2&gt;
  
  
  💥 Performance: Streams vs Traditional
&lt;/h2&gt;

&lt;p&gt;✅ When Streams are Faster or Better:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parallelism: stream().parallel() runs operations on multiple cores.&lt;/li&gt;
&lt;li&gt;Lazy filtering: Stops processing once terminal condition is met.&lt;/li&gt;
&lt;li&gt;Readability: Less boilerplate, easier to reason.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;❌ When They’re Not Ideal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For super simple loops, traditional for may be faster (less overhead).&lt;/li&gt;
&lt;li&gt;Streams create more objects (lambda wrappers, collectors).&lt;/li&gt;
&lt;li&gt;Streams don't allow mutating external state reliably (avoid side effects).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📊 Benchmark instance:
&lt;/h2&gt;

&lt;p&gt;Say you want to sum even numbers from a list of 10 million integers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traditional loop&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="kt"&gt;long&lt;/span&gt; &lt;span class="n"&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="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&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;i&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&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;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&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="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;Stream&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="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter&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;-&amp;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;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;mapToLong&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;Integer:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;longValue&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sum&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;Parallel Stream&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="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;parallelStream&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter&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;-&amp;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;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;mapToLong&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;Integer:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;longValue&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sum&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In practice, parallelStream wins on multi-core machines with large data.&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚔️ Stream vs Loops:
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;For Loop&lt;/th&gt;
&lt;th&gt;Stream&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;😬 verbose&lt;/td&gt;
&lt;td&gt;✅ concise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Functional style&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lazy evaluation&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Parallelism&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;Easy via &lt;code&gt;.parallel()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Control (break/continue)&lt;/td&gt;
&lt;td&gt;✅ Easy&lt;/td&gt;
&lt;td&gt;❌ Not intuitive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;⚡ Best for simple logic&lt;/td&gt;
&lt;td&gt;⚡ Best for complex pipelines&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🚀 Why Streams Are Revolutionary:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Encourage declarative programming. &lt;em&gt;(saying what to do instead how to)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Let you parallelize logic without rewriting loops&lt;/li&gt;
&lt;li&gt;Built for immutable, side-effect-free logic&lt;/li&gt;
&lt;li&gt;Introduced a new mindset to Java programming&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🤔 Why not you go ahead and try these things:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Refactor a for loop using stream()&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;.peek()&lt;/code&gt; to inspect stream data.&lt;/li&gt;
&lt;li&gt;Benchmark &lt;code&gt;.stream()&lt;/code&gt; vs &lt;code&gt;.parallelStream()&lt;/code&gt; performance.&lt;/li&gt;
&lt;li&gt;Write a custom collector.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;And comment down what you learnt in the  process&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can learn more about streams and it's methods and working from articles on baeldung, gfg, oracle docs etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  💬 What's Your Stream Story?
&lt;/h2&gt;

&lt;p&gt;Have a cool use case or a &lt;code&gt;parallelStream()&lt;/code&gt; horror story? Let’s chat in the comments 👇&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>performance</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>You are My-SQL 🧡</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Wed, 05 Feb 2025 17:56:33 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/you-are-my-sql-heart-eac</link>
      <guid>https://forem.com/deadpoolx7/you-are-my-sql-heart-eac</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article assumes you're a beginner—even if you aren't. Just grab a coffee and let's begin. ☕  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why Database? 
&lt;/h2&gt;

&lt;p&gt;In the IT industry, everything revolves around data—collecting it, cleaning it, manipulating it, visualizing it, making sense out of it, and even predicting outcomes based on it. Data is the backbone of modern applications, and we need a structured way to store it—that's where databases come into play.  &lt;/p&gt;

&lt;p&gt;There are two primary types of databases: &lt;strong&gt;SQL (Structured Query Language) databases&lt;/strong&gt; and &lt;strong&gt;NoSQL (Not Only SQL) databases&lt;/strong&gt;.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SQL Databases (Relational Databases)&lt;/strong&gt; are structured as tables containing rows and columns. Examples include &lt;strong&gt;MySQL, MariaDB, PostgreSQL, and Oracle DB&lt;/strong&gt;.  &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NoSQL Databases&lt;/strong&gt; store data in formats like BSON (Binary JSON). A popular example is &lt;strong&gt;MongoDB&lt;/strong&gt;, which is widely used in modern applications.  &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector Databases&lt;/strong&gt; are a relatively new category designed for storing and searching high-dimensional vector embeddings. These are used in AI/ML applications, but for now, we'll focus on &lt;strong&gt;MySQL&lt;/strong&gt;.  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is SQL? 
&lt;/h2&gt;

&lt;p&gt;SQL (Structured Query Language) is the language used to &lt;strong&gt;query, retrieve, and manipulate&lt;/strong&gt; data in relational databases. It enables users to interact with stored data efficiently.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Brewing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Head over to the official MySQL download page: &lt;a href="https://dev.mysql.com/downloads/mysql/" rel="noopener noreferrer"&gt;MySQL Downloads&lt;/a&gt;  &lt;/li&gt;
&lt;li&gt;Install MySQL on your PC following the setup instructions.  &lt;/li&gt;
&lt;li&gt;Run the installer, accept the terms and conditions, and configure it. If you face any issues, search for your OS-specific installation guides on Google or YouTube.  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Accessing MySQL 
&lt;/h3&gt;

&lt;p&gt;Once installed, open your terminal and enter:&lt;br&gt;
&lt;br&gt;
  &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;-u root specifies the user (root is the default administrator).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-p prompts for a password (enter the one you set during installation).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After logging in, check existing databases with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SHOW DATABASES&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lists all available databases, including system-generated ones. You can play with.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: SQL commands are case-insensitive, but using uppercase for keywords (SELECT, FROM, etc.) is a common practice. The semi-colon (;) at the end of commands is required—it marks the end of an SQL statement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Let's create and manage DataBase in MySQL&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Create a Database:&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;CREATE DATABASE LabDB&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see an "OK" message, you're good to go.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To use this database run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;use LabDB&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check for tables (initially, none will exist):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;show tables&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A database contains tables, and a table consists of columns (fields) and rows (records).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;CREATE TABLE Students &lt;span class="o"&gt;(&lt;/span&gt;
    StudentID INT PRIMARY KEY,
    Name VARCHAR&lt;span class="o"&gt;(&lt;/span&gt;255&lt;span class="o"&gt;)&lt;/span&gt; NOT NULL,
    Age INT,
    Department VARCHAR&lt;span class="o"&gt;(&lt;/span&gt;50&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, PRIMARY KEY ensures each record has a unique identifier.&lt;/p&gt;

&lt;p&gt;INT represents an integer data type.&lt;/p&gt;

&lt;p&gt;VARCHAR(n) stores strings (up to n characters).&lt;/p&gt;

&lt;p&gt;NOT NULL enforces that a column must have a value.&lt;/p&gt;

&lt;p&gt;Describe your table, do 'desc' with table name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;desc Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's insert data into Table by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;INSERT INTO Students &lt;span class="o"&gt;(&lt;/span&gt;StudentID, Name, Age, Department&lt;span class="o"&gt;)&lt;/span&gt;  
VALUES 
&lt;span class="o"&gt;(&lt;/span&gt;1, &lt;span class="s1"&gt;'Alice'&lt;/span&gt;, 20, &lt;span class="s1"&gt;'Computer Science'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;,
&lt;span class="o"&gt;(&lt;/span&gt;2, &lt;span class="s1"&gt;'Bob'&lt;/span&gt;, 22, &lt;span class="s1"&gt;'Physics'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;,
&lt;span class="o"&gt;(&lt;/span&gt;3, &lt;span class="s1"&gt;'Charlie'&lt;/span&gt;, 19, &lt;span class="s1"&gt;'Mathematics'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we're simply adding values manually respective to the field type. Notice VarChar field gets a String, Int type got an Integer value.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Created Table, added Values. Now, Let's take a look 👀
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;'*' means all. Select all from Table Name(Students).&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;StudentID&lt;/th&gt;
&lt;th&gt;Name  &lt;/th&gt;
&lt;th&gt;Age&lt;/th&gt;
&lt;th&gt;Department        &lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1        &lt;/td&gt;
&lt;td&gt;Alice &lt;/td&gt;
&lt;td&gt;20 &lt;/td&gt;
&lt;td&gt;Computer Science &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2        &lt;/td&gt;
&lt;td&gt;Bob   &lt;/td&gt;
&lt;td&gt;22 &lt;/td&gt;
&lt;td&gt;Physics          &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3        &lt;/td&gt;
&lt;td&gt;Charlie&lt;/td&gt;
&lt;td&gt;19 &lt;/td&gt;
&lt;td&gt;Mathematics      &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Update and Delete Data
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To update a record:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;UPDATE Students SET Age &lt;span class="o"&gt;=&lt;/span&gt; 21 WHERE StudentID &lt;span class="o"&gt;=&lt;/span&gt; 1&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This updates Alice's age to 21.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To delete Charlie's record:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;DELETE FROM Students WHERE StudentID &lt;span class="o"&gt;=&lt;/span&gt; 3&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use 'Truncate' to remove all records without deleting table
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;TRUNCATE TABLE Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To modify a table structure :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ALTER TABLE Students ADD Email VARCHAR&lt;span class="o"&gt;(&lt;/span&gt;100&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It says to add Email field of type string in our 'Students' table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Filtering Data with WHERE, AND, OR:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use 'where' clause to query specific data :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Department &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Computer Science'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fetches students from the Computer Science department.&lt;/p&gt;

&lt;h2&gt;
  
  
  - AND, OR o
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Using AND/OR operator:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Age &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 18 AND Department &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Physics'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Says to select those students whose age is above 18 and belongs to Physics department.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Age &amp;lt; 18 OR Department &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Biology'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Guess what this does? 😉 (Try it out!)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;See, I feel SQL commands are pretty much self-explanatory and sort of writing English which makes it easy to master.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Using IN, BETWEEN, LIKE, GROUPBY, ORDERBY, HAVING
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;IN ( Multiple values matching)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Department IN &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Computer Science'&lt;/span&gt;, &lt;span class="s1"&gt;'Biology'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fetches students from either department.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BETWEEN (To query between a range)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Age BETWEEN 18 AND 22&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fetches students whose age is between 18 and 22 (inclusive).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LIKE (Pattern matching ):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Name LIKE &lt;span class="s1"&gt;'A%'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finds names starting with 'A'.&lt;br&gt;
(% is a wildcard representing any number of characters).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ORDER BY(Sorting purpose)
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students ORDER BY Age DESC&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;By default &lt;code&gt;ORDER BY&lt;/code&gt; arranges your data in Ascending order.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Group By and Having:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT Department, COUNT&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; FROM Students GROUP BY Department HAVING COUNT&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 5&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using Aggregate Functions:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To get the average:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Select avg&lt;span class="o"&gt;(&lt;/span&gt;Age&lt;span class="o"&gt;)&lt;/span&gt; from Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;To get the Max age:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT MAX&lt;span class="o"&gt;(&lt;/span&gt;Age&lt;span class="o"&gt;)&lt;/span&gt; FROM Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There are others as well.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating Views and Column Aliases:
&lt;/h3&gt;

&lt;p&gt;-  View is a virtual table that stores frequently used queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;CREATE VIEW CS_Students AS  
SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM Students WHERE Department &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Computer Science'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can retrieve only Computer Science students just by using:,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT &lt;span class="k"&gt;*&lt;/span&gt; FROM CS_Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Column Aliases is a way to change how columns are displayed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SELECT Name AS Student_Name, Age AS Student_Age FROM Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Student_Name&lt;/th&gt;
&lt;th&gt;Student_Age&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice      &lt;/td&gt;
&lt;td&gt;21         &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;To delete a table entirely:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;DROP TABLE Students&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;em&gt;What's Next?&lt;/em&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You've learned how to create, insert, retrieve, update, and delete data in MySQL. Now, try JOINs on your own!&lt;/p&gt;

&lt;p&gt;🚀 Challenge:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create another table (Courses).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use INNER JOIN, LEFT JOIN, RIGHT JOIN to combine data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explore user management (GRANT, REVOKE).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Post your results in the comments! See you in the next post—another ☕ awaits.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>beginners</category>
      <category>database</category>
      <category>cli</category>
    </item>
    <item>
      <title>You, me and Computer Networks</title>
      <dc:creator>Sanju Shaw</dc:creator>
      <pubDate>Fri, 17 Jan 2025 11:48:01 +0000</pubDate>
      <link>https://forem.com/deadpoolx7/you-me-and-computer-networks-4e75</link>
      <guid>https://forem.com/deadpoolx7/you-me-and-computer-networks-4e75</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is intended for beginners in Computer Networks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;First of all let's understand what is "Network" in computer?&lt;/p&gt;

&lt;p&gt;Network is defined as the connection of different computers or machines both via wirelessly and wired to the internet.&lt;/p&gt;

&lt;p&gt;Let's assume you have a router, this creates a LAN (Local Area Network) by connecting your devices. These devices need to be within a certain range to maintain a connection, especially if using Wi-Fi. The router itself connects to a WAN (Wide Area Network) through your ISP (Internet Service Provider), providing internet access to your LAN.&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%2Ftefpcwgzp86yrupnnrqc.jpeg" 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%2Ftefpcwgzp86yrupnnrqc.jpeg" alt="internet" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Basic Network Hardware: To connect devices in a network, we use essential hardware like routers, switches, and modems.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A router directs data between your local network (LAN) and the internet, often connecting multiple devices wirelessly or via cables. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Switch&lt;/em&gt; is used within a LAN to connect multiple devices, enabling them to communicate with each other efficiently by forwarding data only to the intended recipient. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Modem&lt;/em&gt; connects your network to your ISP, converting digital data from your devices into a signal that can be transmitted over your internet connection, whether it's cable, DSL, or fiber. Together, these devices form the backbone of most home and business networks.&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%2Fimgs.search.brave.com%2FVnmgh8yWGc55JxWqp5NEgVWMCiuk3wE5mNnngcmDbp4%2Frs%3Afit%3A860%3A0%3A0%3A0%2Fg%3Ace%2FaHR0cHM6Ly93d3cu%2FY2FibGVzLXNvbHV0%2FaW9ucy5jb20vd3At%2FY29udGVudC91cGxv%2FYWRzLzIwMTgvMDgv%2FbW9kZW0tcm91dGVy%2FLXN3aXRjaC1kaWFn%2FcmFtLmpwZw" 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%2Fimgs.search.brave.com%2FVnmgh8yWGc55JxWqp5NEgVWMCiuk3wE5mNnngcmDbp4%2Frs%3Afit%3A860%3A0%3A0%3A0%2Fg%3Ace%2FaHR0cHM6Ly93d3cu%2FY2FibGVzLXNvbHV0%2FaW9ucy5jb20vd3At%2FY29udGVudC91cGxv%2FYWRzLzIwMTgvMDgv%2FbW9kZW0tcm91dGVy%2FLXN3aXRjaC1kaWFn%2FcmFtLmpwZw" alt="network hardwares" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding IP Addresses in Networking
&lt;/h2&gt;

&lt;p&gt;Consider IP addresses like real-life addresses. To send something to a particular place, you need that place's address. Similarly, an IP address is a unique identifier assigned to every machine that wants to send and receive data over the internet. Without IP addresses, devices wouldn't know where to send or receive data.&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%2F4s1fyq36t3k575mxw2zi.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%2F4s1fyq36t3k575mxw2zi.png" alt="ip-pic" width="300" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of IP Addresses
&lt;/h2&gt;

&lt;p&gt;IPv4 and IPv6 An IPv4 address looks like &lt;code&gt;192.168.0.1&lt;/code&gt;. It consists of four numbers separated by dots, with each number ranging from 0 to 255. Due to the limited number of IPv4 addresses, we moved to IPv6, which looks like &lt;code&gt;2001:0db8:85a3:0000:0000:8a2e:0370:7334&lt;/code&gt;. IPv6 provides a much larger pool of addresses, but even with this, managing IP addresses efficiently remains a challenge due to the increasing number of internet-connected devices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Public and Private IP Addresses
&lt;/h2&gt;

&lt;p&gt;img-3&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Public IP Address&lt;/em&gt;&lt;/strong&gt;: Assigned by your ISP, used to connect your network to the internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, 203.0.113.42 might be the public IP address assigned to your home router. This public address is used as the default gateway for your devices to send and receive data from the internet outside your local area network.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Private IP Address&lt;/em&gt;&lt;/strong&gt;: Used within a local network, such as &lt;code&gt;192.168.1.0&lt;/code&gt;, to communicate between devices without using the internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Subnetting
&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%2F8p3dh1jszawgkgb8hsfb.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%2F8p3dh1jszawgkgb8hsfb.png" alt="subnetting-image" width="310" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Subnetting is a method of dividing a large network into smaller, more manageable segments or sub-networks (subnets). This helps improve network performance and security by limiting the number of devices in each subnet.&lt;/p&gt;

&lt;p&gt;Example: If you have a network with the IP range 192.168.1.0/24 (256 addresses), you can create two subnets:&lt;br&gt;
192.168.1.0/25 (128 addresses)&lt;br&gt;
192.168.1.128/25 (128 addresses)&lt;br&gt;
This ensures each subnet can handle up to 128 devices, making network management more efficient.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check your IP address
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Windows&lt;/em&gt;&lt;/strong&gt;: Type ipconfig in Command prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;macOS/Linux&lt;/em&gt;&lt;/strong&gt;: type ifconfig or ip a in terminal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network protocols
&lt;/h2&gt;

&lt;p&gt;By "protocol," we mean a set of rules or standards that define how to complete a task. In networking, a network protocol is a set of rules that devices must follow to send and receive data over the internet. These protocols ensure that data is transferred accurately and securely between devices.&lt;/p&gt;

&lt;p&gt;There are many network protocols, such as FTP, HTTP/HTTPS, SMTP, SSH, ARP, PPP, TCP/IP, TELNET, and more. &lt;br&gt;
For simplicity, we'll focus on TCP/IP, FTP, HTTP/HTTPS, and SMTP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Network Protocols
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;TCP/IP (Transmission Control Protocol/Internet Protocol)&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TCP/IP is the foundation of internet communication. It ensures that data sent over the network is broken into packets, transmitted, and reassembled correctly at the destination.&lt;br&gt;
Example: When you load a webpage, TCP breaks the data into packets, IP routes them, and TCP reassembles them for your browser.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;FTP (File Transfer Protocol)&lt;/em&gt;&lt;/strong&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%2Fztmdt1gsfiab2rkeyo55.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%2Fztmdt1gsfiab2rkeyo55.png" alt="ftp-img" width="316" height="159"&gt;&lt;/a&gt;&lt;br&gt;
FTP is used to transfer files between a client and a server over the internet.&lt;br&gt;
Example: Web developers often use FTP to upload website files from their local computer to a web server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;HTTP/HTTPS (HyperText Transfer Protocol / HyperText Transfer Protocol Secure)&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTTP is the protocol for transferring web pages. HTTPS is the secure version, encrypting data to protect it from interception.&lt;br&gt;
Example: When you visit a website, your browser uses HTTP or HTTPS to request and receive the page's content from the server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;SMTP (Simple Mail Transfer Protocol)&lt;/em&gt;&lt;/strong&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%2F3t5jbdhfo07u462gin5h.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%2F3t5jbdhfo07u462gin5h.png" alt="smtp-image" width="382" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SMTP is used to send emails. It ensures that emails are correctly routed from the sender's server to the recipient's server.&lt;br&gt;
Example: When you hit "send" on an email, SMTP handles the delivery of that message to the recipient's email server.&lt;/p&gt;

&lt;p&gt;These few protocols are essential for the seamless operation of the internet, enabling everything from browsing websites to sending emails.&lt;/p&gt;




&lt;h2&gt;
  
  
  DNS(Domain Naming System)
&lt;/h2&gt;

&lt;p&gt;When you visit a website by entering a domain name in your browser, like '&lt;a href="http://www.dev.to"&gt;www.dev.to&lt;/a&gt;' or 'dev.to', how does the browser know where to go? The browser sends this request to a DNS server, which resolves the domain name to its corresponding IP address.&lt;/p&gt;

&lt;p&gt;The DNS server uses a DNS map table to look up the IP address associated with the domain. Once it finds the correct IP address, it returns this information to the browser, which then uses the IP address to contact the website's server and load the webpage.&lt;/p&gt;

&lt;p&gt;DNS is a complex system involving multiple layers, including root servers, TLD servers, and authoritative name servers. However, this overview provides a simplified explanation to help you grasp the basic concept. The full workings of DNS involve more detailed processes that ensure efficient and reliable domain name resolution.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;If you liked reading consider upvoting, share and comment for more articles revolving around CS fundamentals ;-)&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>computernetwork</category>
      <category>cschallenge</category>
      <category>computerscience</category>
      <category>network</category>
    </item>
  </channel>
</rss>
