<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Java Fundamentals on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/</link><description>Recent content in Java Fundamentals on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/index.xml" rel="self" type="application/rss+xml"/><item><title>Exception Handling and Try-With-Resources</title><link>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/exceptions-and-try-with-resources/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/exceptions-and-try-with-resources/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;An &lt;strong&gt;exception&lt;/strong&gt; is an object that signals that something went wrong and transfers control to the nearest matching &lt;code&gt;catch&lt;/code&gt;. &lt;strong&gt;Try-with-resources&lt;/strong&gt; automatically closes resources such as files, connections and streams, even when exceptions occur.&lt;/p&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Error codes are easy to ignore, and manual cleanup in &lt;code&gt;finally&lt;/code&gt; blocks is verbose and buggy: a second exception during cleanup hides the first. Badly designed exceptions leak implementation details, lose root causes or force callers into empty &lt;code&gt;catch&lt;/code&gt; blocks.&lt;/p&gt;</description></item><item><title>Generics, Wildcards and Type Erasure</title><link>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/generics-and-type-erasure/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/generics-and-type-erasure/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Generics&lt;/strong&gt; let classes, interfaces and methods take &lt;strong&gt;types as parameters&lt;/strong&gt;, such as &lt;code&gt;List&amp;lt;Order&amp;gt;&lt;/code&gt; or &lt;code&gt;Map&amp;lt;String, Price&amp;gt;&lt;/code&gt;. The compiler checks that you put in and take out only the right type. At runtime most of that type information is &lt;strong&gt;erased&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>The Java Collections Framework: Internal Architecture</title><link>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/collections-framework/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/collections-framework/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;strong&gt;Java Collections Framework (JCF)&lt;/strong&gt; is a set of &lt;strong&gt;interfaces&lt;/strong&gt; (&lt;code&gt;List&lt;/code&gt;, &lt;code&gt;Set&lt;/code&gt;, &lt;code&gt;Map&lt;/code&gt;, &lt;code&gt;Queue&lt;/code&gt;, &lt;code&gt;Deque&lt;/code&gt;), &lt;strong&gt;implementations&lt;/strong&gt; (&lt;code&gt;ArrayList&lt;/code&gt;, &lt;code&gt;HashMap&lt;/code&gt;, &lt;code&gt;TreeMap&lt;/code&gt; and others) and &lt;strong&gt;algorithms&lt;/strong&gt; (&lt;code&gt;Collections.sort&lt;/code&gt;, &lt;code&gt;binarySearch&lt;/code&gt;) for storing and processing groups of objects.&lt;/p&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Choosing the wrong collection is one of the most common hidden performance bugs: &lt;code&gt;contains&lt;/code&gt; on a large &lt;code&gt;ArrayList&lt;/code&gt; is O(n), and &lt;code&gt;LinkedList.get(i)&lt;/code&gt; walks the list. Mutable keys break &lt;code&gt;HashMap&lt;/code&gt;. Knowing the internals tells you the costs.&lt;/p&gt;</description></item><item><title>Modern Java: Records, Sealed Classes and Pattern Matching</title><link>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/modern-java-features/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/modern-java-features/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Modern Java (16 to 21, refined through 25 LTS and 27) adds features for modelling &lt;strong&gt;data as data&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;records&lt;/strong&gt; for transparent, immutable data carriers&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;sealed types&lt;/strong&gt; for closed sets of alternatives&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;pattern matching&lt;/strong&gt; to safely take data apart and branch on its shape.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Together these are called &lt;strong&gt;data-oriented programming&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Reflection API and Dynamic Proxies</title><link>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/reflection-and-dynamic-proxies/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/java/fundamentals/reflection-and-dynamic-proxies/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Reflection&lt;/strong&gt; lets a program &lt;strong&gt;inspect and use&lt;/strong&gt; classes, methods, fields, constructors and annotations &lt;strong&gt;at runtime&lt;/strong&gt;, without knowing them at compile time.&lt;/li&gt;&#10;&lt;li&gt;A &lt;strong&gt;dynamic proxy&lt;/strong&gt; is an object created at runtime that &lt;strong&gt;implements interfaces&lt;/strong&gt; (or subclasses a class) and routes every method call through your handler code.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Together they are the engine behind dependency injection, AOP, ORMs, serialisation and test mocks.&lt;/p&gt;</description></item></channel></rss>