<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rajender Singh  on Medium]]></title>
        <description><![CDATA[Stories by Rajender Singh  on Medium]]></description>
        <link>https://medium.com/@rajendersingh.1193?source=rss-5df8667e2ab0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tOGCNfFMCE6HLfEpEQfJ-A.jpeg</url>
            <title>Stories by Rajender Singh  on Medium</title>
            <link>https://medium.com/@rajendersingh.1193?source=rss-5df8667e2ab0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:05:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajendersingh.1193/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ What is a Lambda Expression in Java? Part-3]]></title>
            <link>https://medium.com/@rajendersingh.1193/what-is-a-lambda-expression-in-java-part-3-7d9df7d0d0ee?source=rss-5df8667e2ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d9df7d0d0ee</guid>
            <dc:creator><![CDATA[Rajender Singh ]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 14:43:04 GMT</pubDate>
            <atom:updated>2025-06-25T14:43:04.093Z</atom:updated>
            <content:encoded><![CDATA[<p>A <strong>Lambda Expression</strong> is a short block of code that takes in parameters and returns a value.<br> It’s Java’s way of enabling <strong>functional programming</strong>, introduced in <strong>Java 8</strong>.</p><h3>✅ Syntax of Lambda</h3><pre>(parameters) -&gt; expression</pre><p>Or, for multiple statements:</p><pre>(parameters) -&gt; {<br>    // multiple lines of code<br>    return result;<br>}</pre><h3>🧠 Why Use Lambdas?</h3><ul><li>Makes code <strong>shorter</strong> and <strong>more readable</strong></li><li>Great for working with <strong>Streams</strong>, <strong>Collections</strong>, and <strong>functional interfaces</strong></li><li>Helps pass <strong>behavior as data</strong> (functional programming)</li></ul><h3>🔧 Requirements for Lambda Usage</h3><p>You can only use lambdas with a <strong>Functional Interface</strong> — an interface with exactly one abstract method.</p><p>Example:</p><pre>@FunctionalInterface<br>interface Greeting {<br>    void sayHello();<br>}</pre><p>Lambda usage:</p><pre>Greeting g = () -&gt; System.out.println(&quot;Hello Raj!&quot;);<br>g.sayHello();</pre><h3>Different Ways to Write Lambda Expressions:</h3><p>Lambda expressions in Java 8 can be written in <strong>multiple styles</strong>, depending on the number of parameters, the presence of return statements, and the block syntax. Here’s a complete guide:</p><h3>📌 1. No Parameter Lambda</h3><p>Used when no arguments are passed.</p><pre>Runnable task = () -&gt; System.out.println(&quot;Running without parameters&quot;);<br>task.run();</pre><h3>📌 2. Single Parameter — No Parentheses</h3><p>If there’s only <strong>one parameter</strong>, parentheses can be omitted.</p><pre>Consumer&lt;String&gt; greet = message -&gt; System.out.println(&quot;Hello &quot; + message);<br>greet.accept(&quot;Raj&quot;);  // Output: Hello Raj</pre><h3>📌 3. Single Parameter — With Parentheses</h3><p>Parentheses are <strong>optional</strong> for one parameter, but allowed.</p><pre>Consumer&lt;String&gt; greet = (message) -&gt; System.out.println(&quot;Hello &quot; + message);</pre><h3>📌 4. Multiple Parameters</h3><p>Use parentheses when there are <strong>two or more parameters</strong>.</p><pre>BiFunction&lt;Integer, Integer, Integer&gt; sum = (a, b) -&gt; a + b;<br>System.out.println(sum.apply(10, 20)); // Output: 30</pre><h3>📌 5. Multiple Statements in Body</h3><p>Use <strong>curly braces </strong><strong>{}</strong> and explicitly write the return statement if your lambda has multiple lines.</p><pre>BiFunction&lt;Integer, Integer, Integer&gt; multiply = (a, b) -&gt; {<br>    int result = a * b;<br>    return result;<br>};<br>System.out.println(multiply.apply(4, 5)); // Output: 20</pre><h3>📌 6. Lambda with Return Statement</h3><p>Even in single-line blocks, you can write a return, especially when using curly braces.</p><pre>Function&lt;Integer, Boolean&gt; isEven = x -&gt; {<br>    return x % 2 == 0;<br>};</pre><blockquote><em>❗ If you use curly braces </em><em>{}, you </em><strong><em>must</em></strong><em> use the </em><em>return keyword.</em></blockquote><h3>📌 7. Lambda with Type Declaration (Explicit Types)</h3><p>Java usually infers types, but you can specify them.</p><pre>BiFunction&lt;Integer, Integer, Integer&gt; subtract = (Integer a, Integer b) -&gt; a - b;<br>System.out.println(subtract.apply(10, 3)); // Output: 7</pre><h3>✅ Summary Table: Lambda Expression Styles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQ1RdS-HjYZVmQb-ulUv9Q.png" /><figcaption>Summary Lambda</figcaption></figure><h3>🔥 Real-World Usage in Streams</h3><pre>List&lt;String&gt; names = Arrays.asList(&quot;Raj&quot;, &quot;Ravi&quot;, &quot;John&quot;);</pre><pre>names.stream()<br>    .filter(name -&gt; name.startsWith(&quot;R&quot;))<br>    .map(String::toUpperCase)<br>    .forEach(System.out::println);</pre><pre>// Output:<br>// RAJ<br>// RAVI</pre><h3>🧠 Common Use-Cases</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JftriqipV0pGCK4Sh5C3Gw.png" /></figure><h3>🧠 Final Thoughts</h3><p>Lambda expressions have revolutionized how we write Java code, bringing it closer to modern functional programming paradigms. Whether you’re writing concise logic for filtering a stream, defining a behavior on the fly, or building clean APIs, <strong>lambdas make your code more expressive and elegant</strong>.</p><p>By mastering the different ways to write lambdas and understanding how they tie into functional interfaces, you improve code readability and unlock the full power of Java 8 and beyond.</p><blockquote><em>“Write less, do more” — that’s the spirit of lambdas in Java.</em></blockquote><p>If you’re serious about writing <strong>modern, clean Java code</strong>, lambdas are no longer optional—they’re essential.</p><p>Java, Functional Programming, Java 8, Lambda, Streams, Backend Development, Tech Interview, Software Engineering</p><p>Stay tuned...</p><p>Happy Coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d9df7d0d0ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ What Is a Functional Interface in Java? Part:2]]></title>
            <link>https://medium.com/@rajendersingh.1193/what-is-a-functional-interface-in-java-part-1-66f388757b31?source=rss-5df8667e2ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/66f388757b31</guid>
            <dc:creator><![CDATA[Rajender Singh ]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 16:05:17 GMT</pubDate>
            <atom:updated>2025-06-22T16:17:32.969Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Complete Guide with Examples, Interview Q&amp;A, and Cheat Sheet</h3><p>Java 8 introduced <strong>lambda expressions</strong>, <strong>method references</strong>, and <strong>streams</strong>, and at the heart of all of these is the <strong>Functional Interface</strong>.</p><p>This guide covers:</p><ul><li>✅ What it is</li><li>🧪 Real code examples</li><li>🧠 Interview questions</li><li>📄 Cheat sheet of all built-in functional interfaces</li></ul><h3>✅ What Is a Functional Interface?</h3><p>A <strong>Functional Interface</strong> is an interface in Java that contains <strong>exactly one abstract method</strong>. It is used as a <strong>target type</strong> for lambda expressions and method references.</p><pre>@FunctionalInterface<br>interface MyTask {<br>    void execute();<br>}</pre><h3>🧠 Why “Functional”?</h3><p>Because it behaves like a <strong>mathematical function</strong> — one input, one output.</p><h3>✨ Using a Functional Interface with a Lambda</h3><pre>MyTask task = () -&gt; System.out.println(&quot;Task running!&quot;);<br>task.execute(); // Output: Task running!</pre><h3>📋 Rules of Functional Interfaces</h3><p>✅ Rule Description:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1JlNbrVr3nPSGzOf6zAK8A.png" /><figcaption>Functional Interface</figcaption></figure><h3>📦 Built-in Functional Interfaces in Java 8</h3><p>Java provides many built-in functional interfaces in java.util.function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0IPAleFsqtRpTNw7OIXWtA.png" /></figure><h3>🧪 Real Examples</h3><h3>✅ Using Predicate&lt;T&gt; to Filter a List</h3><pre>Predicate&lt;String&gt; startsWithR = name -&gt; name.startsWith(&quot;R&quot;);</pre><pre>List&lt;String&gt; names = Arrays.asList(&quot;Raj&quot;, &quot;Ravi&quot;, &quot;Mona&quot;);<br>List&lt;String&gt; filtered = names.stream()<br>    .filter(startsWithR)<br>    .collect(Collectors.toList());</pre><pre>System.out.println(filtered); // [Raj, Ravi]</pre><h3>✅ Using Function&lt;T, R&gt; for Transformation</h3><pre>Function&lt;String, Integer&gt; lengthFunction = str -&gt; str.length();</pre><pre>System.out.println(lengthFunction.apply(&quot;Raj&quot;)); // Output: 3</pre><h3>✅ Using Supplier&lt;T&gt; for Lazy Loading</h3><pre>Supplier&lt;String&gt; greeting = () -&gt; &quot;Hello, Raj!&quot;;<br>System.out.println(greeting.get()); // Hello, Raj!</pre><p>🔨 Create Your Own Functional Interface</p><pre>🔨 Create Your Own Functional Interface<br><br>@FunctionalInterface<br>interface Calculator {<br>    int operate(int a, int b);<br>}</pre><pre>Calculator add = (a, b) -&gt; a + b;<br>Calculator multiply = (a, b) -&gt; a * b;</pre><pre>System.out.println(add.operate(5, 3));      // 8<br>System.out.println(multiply.operate(5, 3)); // 15</pre><h3>🚫 Common Mistakes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUohOjVFVYdwOIkHe-42bA.png" /></figure><h3>🧠 Java Interview Questions: Functional Interfaces</h3><h3>1️⃣ What is a functional interface in Java?</h3><p><strong>Answer</strong>: An interface with exactly one abstract method. Used as a lambda expression target.</p><h3>2️⃣ Can a functional interface have default or static methods?</h3><p><strong>Answer</strong>: Yes, as long as there’s only one abstract method.</p><h3>3️⃣ What is the use of @FunctionalInterface annotation?</h3><p><strong>Answer</strong>: It tells the compiler to enforce that the interface has only one abstract method.</p><h3>4️⃣ Give an example of a built-in functional interface.</h3><p><strong>Answer</strong>: Predicate&lt;T&gt; — used to filter streams based on a condition.</p><h3>5️⃣ Can we create our own functional interface?</h3><p><strong>Answer</strong>: Yes. Just define an interface with one abstract method and optionally use @FunctionalInterface.</p><h3>6️⃣ What’s the difference between Function&lt;T,R&gt; and Predicate&lt;T&gt;?</h3><p><strong>Answer</strong>:</p><ul><li>Function&lt;T, R&gt; takes T and returns R</li><li>Predicate&lt;T&gt; takes T and returns boolean</li></ul><h3>7️⃣ What’s the difference between Consumer&lt;T&gt; and Supplier&lt;T&gt;?</h3><p><strong>Answer</strong>:</p><ul><li>Consumer&lt;T&gt; accepts a value and returns nothing</li><li>Supplier&lt;T&gt; returns a value and takes nothing</li></ul><h3>🧾 Final Summary</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ktm44cgZE_MlRK_G80WAMg.png" /></figure><h3>📢 Final Thoughts</h3><p>Functional Interfaces are the <strong>backbone of Java 8’s functional programming model</strong>. Mastering them makes your code <strong>cleaner, testable</strong>, and more <strong>modern</strong>.</p><p>Java, Functional Programming, Java 8, Lambda, Streams, Backend Development, Tech Interview, Software Engineering</p><p>Stay Tuned</p><p>Happy Coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66f388757b31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java 8 Features Explained with Real-World Examples: Part-1]]></title>
            <link>https://medium.com/@rajendersingh.1193/java-8-features-explained-with-real-world-examples-part-1-d05ed0ab5c27?source=rss-5df8667e2ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d05ed0ab5c27</guid>
            <dc:creator><![CDATA[Rajender Singh ]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 15:22:53 GMT</pubDate>
            <atom:updated>2025-06-22T15:22:53.668Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Everything a developer should know — with code, use-cases, and tips.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*a8vDCcJx9rx_hiw9MnvPBA.png" /><figcaption>java8</figcaption></figure><p>Java 8 introduced powerful features that made Java programming more expressive, concise, and functional. This guide explains all major features, along with practical examples and real-world use cases.</p><h3>✅ 1. Lambda Expressions</h3><h3>🔹 What it is:</h3><p>Anonymous functions to write clean and concise functional code.</p><h3>🧪 Example:</h3><pre>Runnable task = () -&gt; System.out.println(&quot;Running task&quot;);<br>new Thread(task).start();</pre><h3>✅ 2. Functional Interfaces</h3><h3>🔹 What it is:</h3><p>Interfaces with exactly one abstract method. Used as lambda targets.</p><h3>🧪 Example:</h3><pre>@FunctionalInterface<br>interface Greeting {<br>    void sayHello();<br>}</pre><pre>Greeting greet = () -&gt; System.out.println(&quot;Hello!&quot;);<br>greet.sayHello();</pre><h3>✅ 3. Stream API</h3><h3>🔹 What it is:</h3><p>A powerful API to process collections in a functional style.</p><h3>🧪 Example:</h3><pre>List&lt;String&gt; names = Arrays.asList(&quot;Raj&quot;, &quot;Ravi&quot;, &quot;Reena&quot;, &quot;Mona&quot;);</pre><pre>names.stream()<br>     .filter(name -&gt; name.startsWith(&quot;R&quot;))<br>     .map(String::toUpperCase)<br>     .forEach(System.out::println);</pre><h3>✅ 4. Default &amp; Static Methods in Interfaces</h3><h3>🧪 Example:</h3><pre>interface Vehicle {<br>    default void start() {<br>        System.out.println(&quot;Vehicle started&quot;);<br>    }</pre><pre>    static void info() {<br>        System.out.println(&quot;Vehicle info&quot;);<br>    }<br>}</pre><h3>✅ 5. Method References</h3><h3>🔹 What it is:</h3><p>Shortcut for lambda expressions that just call a method.</p><h3>🧪 Example:</h3><pre>List&lt;String&gt; fruits = Arrays.asList(&quot;Banana&quot;, &quot;Mango&quot;, &quot;Apple&quot;);<br>fruits.forEach(System.out::println);</pre><h3>✅ 6. Optional Class</h3><h3>🔹 What it is:</h3><p>Container to represent the presence or absence of a value (null safety).</p><h3>🧪 Example:</h3><pre>Optional&lt;String&gt; name = Optional.ofNullable(&quot;Raj&quot;);<br>System.out.println(name.orElse(&quot;Default&quot;));</pre><h3>✅ 7. New Date and Time API</h3><h3>🔹 What it is:</h3><p>Immutable and thread-safe replacements for Date and Calendar.</p><h3>🧪 Example:</h3><pre>LocalDate today = LocalDate.now();<br>LocalDate birthday = LocalDate.of(1992, Month.JANUARY, 1);<br>System.out.println(ChronoUnit.YEARS.between(birthday, today));</pre><h3>✅ 8. Collectors API</h3><h3>🧪 Example:</h3><pre>List&lt;String&gt; names = Arrays.asList(&quot;raj&quot;, &quot;varsha&quot;, &quot;john&quot;);</pre><pre>List&lt;String&gt; upperNames = names.stream()<br>    .map(String::toUpperCase)<br>    .collect(Collectors.toList());</pre><h3>✅ 9. Parallel Streams</h3><h3>🧪 Example:</h3><pre>List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5, 6);</pre><pre>numbers.parallelStream()<br>       .forEach(n -&gt; System.out.println(n + &quot; - &quot; + Thread.currentThread().getName()));</pre><h3>✅ 10. Nashorn JavaScript Engine</h3><h3>🧪 Example:</h3><pre>ScriptEngine engine = new ScriptEngineManager().getEngineByName(&quot;nashorn&quot;);<br>engine.eval(&quot;print(&#39;Hello from JavaScript&#39;)&quot;);</pre><h3>✅ 11. Ways to Write Lambda Expressions</h3><p>Style Example No Parameter () -&gt; println(&quot;Hi&quot;) Single Param, No Brackets x -&gt; x * 2 Single Param, With Brackets (x) -&gt; x * 2 Multiple Params (a, b) -&gt; a + b With Block &amp; Return (x, y) -&gt; { return x * y; } With Type Declaration (Integer x, Integer y) -&gt; x + y</p><h3>✅ 12. Stream Built-in Functions — What, Why, and How</h3><p>Method Purpose Example filter() Filter items by condition .filter(x -&gt; x &gt; 10) map() Transform each item .map(String::toUpperCase) reduce() Combine to single result .reduce(0, (a,b) -&gt; a + b) collect() Convert to List/Set/Map .collect(Collectors.toList()) sorted() Sort stream .sorted() distinct() Remove duplicates .distinct() limit() Limit number of results .limit(5) skip() Skip first n items .skip(3) anyMatch() True if any match condition .anyMatch(x -&gt; x &gt; 10) allMatch() True if all match condition .allMatch(x -&gt; x != null) noneMatch() True if none match .noneMatch(x -&gt; x &lt; 0) findFirst() Find first element .findFirst() count() Count elements .count()</p><h3>🧠 Tips for Using Streams</h3><p>Use Case Recommended Methods Filter values filter() Transform data map() Summarize results reduce() Convert to collection collect() Remove duplicates distinct() Get top/bottom elements limit(), skip() Check for conditions anyMatch(), allMatch() Get first match findFirst() Count elements count() Sort data sorted()</p><h3>🎯 Summary</h3><p>Java 8 introduced a powerful set of tools that changed how Java developers write code. From functional programming with lambdas and streams to better date/time handling and default interface methods, it made Java has become modern and expressive.</p><p>#Java8 #FunctionalProgramming #SoftwareDevelopment #Coding #JavaTutorial #Programming #JavaDevelopment #LearnToCode #ModernProgramming</p><p>Stay tuned 👇</p><p>Happy Coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d05ed0ab5c27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[☕️Java Versions and Their Must-Know Features: From Java 5 to Java 22]]></title>
            <link>https://medium.com/@rajendersingh.1193/java-versions-and-their-must-know-features-from-java-5-to-java-22-c856821288db?source=rss-5df8667e2ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c856821288db</guid>
            <dc:creator><![CDATA[Rajender Singh ]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 14:30:19 GMT</pubDate>
            <atom:updated>2025-08-17T09:07:02.752Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*ADhInS6_XTj29LpWvHYvjA.png" /><figcaption>Java Version</figcaption></figure><p>Your ultimate guide to Java 1.5 to Java 22, highlighting the top features every developer needs to master for modern programming.</p><p><em>Alt text: Java logo with a blurred code editor background, symbolizing Java programming.</em></p><p>Java has transformed from a robust but verbose language into a modern, concise, and high-performance platform. Since Java 1.5 in 2004, each release has introduced game-changing features, enhancing developer productivity and code efficiency. In this comprehensive guide, we explore key Java versions up to Java 22 (2024), spotlighting must-know features with practical examples to help you level up your coding skills.</p><p>Whether you’re a beginner or a seasoned developer, this post is your roadmap to understanding Java’s evolution. Let’s dive in!</p><h3>✨Java 1.5 (Java 5) — Released in 2004</h3><p>Java 5 was a landmark release, introducing features that revolutionized Java programming.</p><h3>Must-Know Features:</h3><ul><li><strong>Generics</strong>: Type-safe collections without casting.</li><li><strong>Enhanced for-loop</strong>: Simplified iteration over collections and arrays.</li><li><strong>Autoboxing/Unboxing</strong>: Automatic conversion between primitives and wrapper classes.</li><li><strong>Varargs</strong>: Flexible method arguments.</li><li><strong>Annotations</strong>: Metadata for code, enabling better tooling and frameworks.</li></ul><h3>Example Code:</h3><pre><br>List&lt;String&gt; list = new ArrayList&lt;String&gt;();<br>list.add(&quot;Hello&quot;);<br>String s = list.get(0); // No cast needed<br></pre><pre>// Enhanced for-loop<br>for (String name : list) {<br>    System.out.println(name);<br>}</pre><pre>// Autoboxing/Unboxing<br>Integer x = 10; // Autoboxing<br>int y = x; // Unboxing</pre><pre>// Varargs<br>public void printAll(String... args) {<br>    for (String s : args) System.out.println(s);<br>}</pre><pre>// Annotations<br>@Override<br>public String toString() {<br>    return &quot;Java 5&quot;;<br>}</pre><h3>✨Java 6 — Released in 2006</h3><p>Java 6 focused on performance and integration, with fewer but impactful features.</p><h3>Must-Know Features:</h3><ul><li><strong>Scripting Engine (JSR 223)</strong>: Run scripts (e.g., JavaScript) within Java.</li><li><strong>Performance Improvements</strong>: Better JVM and garbage collection.</li><li><strong>JDBC 4.0</strong>: Simplified database connectivity.</li></ul><h3>Example Code:</h3><pre>// Scripting Engine<br>ScriptEngineManager manager = new ScriptEngineManager();<br>ScriptEngine engine = manager.getEngineByName(&quot;JavaScript&quot;);<br>engine.eval(&quot;print(&#39;Hello from JS&#39;)&quot;);</pre><pre>// JDBC 4.0 (no manual driver loading)<br>Connection conn = DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/test&quot;, &quot;user&quot;, &quot;pass&quot;);</pre><h3>✨Java 7 — Released in 2011</h3><p>Java 7 introduced developer-friendly features to simplify code and improve robustness.</p><h3>Must-Know Features:</h3><ul><li><strong>Try-with-resources</strong>: Automatic resource management.</li><li><strong>Diamond Operator</strong>: Simplified generic type inference.</li><li><strong>Strings in switch</strong>: Use strings in switch statements.</li><li><strong>Multi-catch Block</strong>: Handle multiple exceptions in one catch.</li></ul><h3>Example Code:</h3><pre>// Try-with-resources<br>try (BufferedReader br = new BufferedReader(new FileReader(&quot;file.txt&quot;))) {<br>    System.out.println(br.readLine());<br>}</pre><pre>// Diamond Operator<br>Map&lt;String, List&lt;String&gt;&gt; map = new HashMap&lt;&gt;();</pre><pre>// Strings in switch<br>switch (&quot;java&quot;) {<br>    case &quot;java&quot;: System.out.println(&quot;Language&quot;); break;<br>}</pre><pre>// Multi-catch block<br>try {<br>    // code<br>} catch (IOException | SQLException ex) {<br>    ex.printStackTrace();<br>}</pre><h3>✨Java 8 — Released in 2014</h3><p>Java 8 was a game-changer, introducing functional programming paradigms.</p><h3>Must-Know Features:</h3><ul><li><strong>Lambda Expressions</strong>: Concise function syntax.</li><li><strong>Streams API</strong>: Functional-style data processing.</li><li><strong>Functional Interfaces</strong>: Single-method interfaces for lambdas.</li><li><strong>Optional</strong>: Handle null values gracefully.</li><li><strong>Default &amp; Static Methods in Interfaces</strong>: Add methods without breaking implementations.</li></ul><h3>Example Code:</h3><pre>// Lambda &amp; Stream<br>List&lt;String&gt; names = Arrays.asList(&quot;Raj&quot;, &quot;Rohan&quot;, &quot;Singh&quot;);<br>names.stream().filter(n -&gt; n.startsWith(&quot;R&quot;)).forEach(System.out::println);</pre><pre>// Optional<br>Optional&lt;String&gt; name = Optional.ofNullable(null);<br>System.out.println(name.orElse(&quot;Default&quot;));</pre><pre>// Default methods in interfaces<br>interface Vehicle {<br>    default void start() {<br>        System.out.println(&quot;Starting…&quot;);<br>    }<br>}</pre><h3>✨Java 9 — Released in 2017</h3><p>Java 9 introduced modularity, transforming how Java applications are built.</p><h3>Must-Know Features:</h3><ul><li><strong>Module System (JPMS)</strong>: Encapsulate code for better scalability.</li><li><strong>jshell (REPL)</strong>: Interactive Java shell for rapid prototyping.</li><li><strong>Stream Improvements</strong>: New methods like takeWhile and dropWhile.</li><li><strong>Private Methods in Interfaces</strong>: Reuse code within interfaces.</li></ul><h3>Example Code:</h3><pre>// jshell<br>jshell&gt; int a = 10;<br>jshell&gt; a * 2<br>20</pre><pre>// Stream.takeWhile<br>List&lt;Integer&gt; list = List.of(1, 2, 3, 4, 5);<br>list.stream().takeWhile(i -&gt; i &lt; 4).forEach(System.out::println);</pre><h3>✨Java 10 — Released in 2018</h3><p>Java 10 introduced local variable type inference for cleaner code.</p><h3>Must-Know Features:</h3><ul><li><strong>Local Variable Type Inference (var)</strong>: Reduce boilerplate with var.</li></ul><h3>Example Code:</h3><pre>var map = new HashMap&lt;String, Integer&gt;();<br>map.put(&quot;age&quot;, 30);</pre><h3>✨Java 11 — Released in 2018</h3><p>Java 11, a long-term support (LTS) release, standardized key APIs.</p><h3>Must-Know Features:</h3><ul><li><strong>String Methods</strong>: lines, repeat, isBlank for text processing.</li><li><strong>Running Single-File Programs</strong>: Execute .java files directly.</li><li><strong>HttpClient API</strong>: Modern HTTP client for web interactions.</li></ul><h3>Example Code:</h3><pre>// String methods<br>String s = &quot;Hello\nWorld&quot;;<br>s.lines().forEach(System.out::println);<br>System.out.println(&quot;*&quot;.repeat(3));</pre><pre>// HttpClient<br>HttpClient client = HttpClient.newHttpClient();<br>HttpRequest request = HttpRequest.newBuilder().uri(URI.create(&quot;https://example.com&quot;)).build();<br>client.sendAsync(request, HttpResponse.BodyHandlers.ofString())<br>      .thenAccept(System.out::println);</pre><p><em>Alt text: A developer typing Java code in a modern IDE, showcasing software development.</em></p><h3>✨Java 12 — Released in 2019</h3><p>Java 12 introduced preview features for cleaner switch statements.</p><h3>Must-Know Features:</h3><ul><li><strong>Switch Expressions (Preview)</strong>: Concise switch syntax with arrow notation.</li></ul><h3>Example Code:</h3><pre>String result = switch (3) {<br>    case 1 -&gt; &quot;One&quot;;<br>    case 2 -&gt; &quot;Two&quot;;<br>    default -&gt; &quot;Other&quot;;<br>};</pre><h3>✨Java 13 — Released in 2019</h3><p>Java 13 enhanced text handling with text blocks.</p><h3>Must-Know Features:</h3><ul><li><strong>Text Blocks (Preview)</strong>: Multi-line strings without escape sequences.</li></ul><h3>Example Code:</h3><pre>String html = &quot;&quot;&quot;<br>    &lt;html&gt;<br>    &lt;body&gt;Hello&lt;/body&gt;<br>    &lt;/html&gt;<br>    &quot;&quot;&quot;;</pre><h3>✨Java 14 — Released in 2020</h3><p>Java 14 introduced records and improved error messages.</p><h3>Must-Know Features:</h3><ul><li><strong>Records (Preview)</strong>: Immutable data carriers.</li><li><strong>Helpful NullPointerExceptions</strong>: Detailed NPE messages.</li></ul><h3>Example Code:</h3><pre>// Record<br>record Person(String name, int age) {}</pre><pre>// NPE messages<br>String test = null;<br>test.length(); // Shows variable name in error</pre><h3>✨Java 15 — Released in 2020</h3><p>Java 15 standardized text blocks and introduced sealed classes.</p><h3>Must-Know Features:</h3><ul><li><strong>Text Blocks (Standardized)</strong>: Multi-line strings finalized.</li><li><strong>Sealed Classes (Preview)</strong>: Restrict class inheritance.</li></ul><h3>Example Code:</h3><pre>public sealed class Vehicle permits Car, Truck {}</pre><h3>✨Java 16 — Released in 2021</h3><p>Java 16 simplified type checking with pattern matching.</p><h3>Must-Know Features:</h3><ul><li><strong>Pattern Matching for instanceof</strong>: Eliminate explicit casting.</li><li>Records (Finalized).</li><li>Warnings for Value-Based Classes.</li><li>jpackage: a Tool for packaging apps.</li><li>Strong Encapsulation of JDK internals.</li></ul><h3>Example Code:</h3><pre>if (obj instanceof String s) {<br>    System.out.println(s.toLowerCase());<br>}</pre><h3>✨Java 17 (LTS) — Released in 2021</h3><p>Java 17, another LTS release, solidified modern Java features.</p><h3>Must-Know Features:</h3><ul><li><strong>Sealed Classes (Standard)</strong>: Control inheritance hierarchies.</li><li><strong>Pattern Matching</strong>: Enhanced type checking.</li><li><strong>Switch Enhancements</strong>: Improved switch expressions.</li><li><strong>macOS Rendering Pipeline</strong>: Better macOS support.</li></ul><h3>✨Java 18 — Released in 2022</h3><p>Java 18 introduced tools for prototyping.</p><h3>Must-Know Features:</h3><ul><li><strong>Simple Web Server</strong>: Lightweight server for testing (jwebserver).</li></ul><h3>Example Code:</h3><pre>jwebserver</pre><h3>✨Java 19 — Released in 2022</h3><p>Java 19 previewed virtual threads for concurrency.</p><h3>Must-Know Features:</h3><ul><li><strong>Virtual Threads (Preview)</strong>: Lightweight threads for scalability.</li></ul><h3>✨Java 20 — Released in 2023</h3><p>Java 20 enhanced pattern matching and data sharing.</p><p><strong>Must-Know Features:</strong></p><ul><li>Scoped Values (Incubator).</li><li>Record Patterns (Preview).</li></ul><h3>Must-Know Features:</h3><ul><li><strong>Scoped Values</strong>: Share immutable data across threads.</li><li><strong>Record Patterns (Preview)</strong>: Deconstruct records in patterns.</li></ul><h3>✨Java 21 (LTS) — Released in 2023</h3><p>Java 21, an LTS release, standardized virtual threads and advanced pattern matching.</p><h3>Must-Know Features:</h3><ul><li><strong>Virtual Threads (Standard)</strong>: High-throughput concurrency.</li><li><strong>Record Patterns &amp; Pattern Matching for switch</strong>: Enhanced data deconstruction.</li><li><strong>Sequenced Collections</strong>: Ordered collections API.</li><li><strong>String Templates (Preview)</strong>: Simplified string interpolation.</li></ul><h3>Example Code:</h3><pre>Thread.startVirtualThread(() -&gt; System.out.println(&quot;Running light-weight thread&quot;));</pre><h3>✨Java 22 — Released in 2024</h3><p>Java 22 focused on performance and native integration.</p><h3>Must-Know Features:</h3><ul><li><strong>Stream Gatherers</strong>: Custom stream operations.</li><li><strong>Foreign Function &amp; Memory API (Improved)</strong>: Native code integration.</li><li>Stream Gatherers (Preview).</li><li>Foreign Function &amp; Memory API (Finalized).</li><li>Class-File API.</li><li>Multi-File Source-Code Launching.</li></ul><p><em>Alt text: Java 22 code running in an IDE, highlighting modern Java features.</em></p><h3>Final Thoughts</h3><p>Java’s evolution from Java 5 to Java 22 showcases its adaptability and commitment to developer productivity. Features like lambdas, records, virtual threads, and pattern matching have transformed Java into a modern, expressive language. For production, stick to LTS versions (Java 17 or 21), but experiment with newer releases to stay ahead.</p><p>Which Java feature has been a game-changer for you? Share in the comments, and let’s discuss Java’s exciting future!</p><p>#Java #JavaFeatures #Programming #SoftwareDevelopment #Coding #OpenJDK #JavaVersions #DeveloperTools #Tech</p><p>Java versions, Java features, Java programming, Java 5 to 22, Java LTS, Java developer guide, modern Java, Java coding tips</p><p>Happy Coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c856821288db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essential System Design Concepts for Beginners]]></title>
            <link>https://medium.com/@rajendersingh.1193/essential-system-design-concepts-for-beginners-fed519f06ba2?source=rss-5df8667e2ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fed519f06ba2</guid>
            <dc:creator><![CDATA[Rajender Singh ]]></dc:creator>
            <pubDate>Tue, 17 Jun 2025 01:12:13 GMT</pubDate>
            <atom:updated>2025-06-17T01:12:13.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*Qvc0x9ji8f2k_RvyPA6BuA.png" /></figure><p>If you’re new to system design, this guide will introduce key concepts that help in building scalable and reliable software systems. Whether you’re preparing for an interview or just want to improve your knowledge, this article will provide a solid foundation.</p><p>1️⃣ **Server Basics**<br>A server is a computer that handles requests from users (clients). When you open a website, your browser sends a request to a server, which processes it and sends back the response.</p><p>Example: When you search for something on Google, their servers fetch and return results to you.<br>2️⃣ **Latency vs. Throughput**<br>Latency = Time taken to process a single request (lower is better).<br>Throughput = Number of requests a system can handle per second (higher is better).<br>✅ Goal: Reduce latency and maximize throughput for a fast and efficient system.</p><p>3️⃣ **Scaling: Vertical vs. Horizontal**<br>Vertical Scaling (Scaling Up) → Add more power (CPU, RAM) to a single server.<br>Horizontal Scaling (Scaling Out) → Add more servers to handle more users.<br>✅ Example: YouTube scales horizontally by adding more servers to handle millions of videos.</p><p>4️⃣ **Database Indexing &amp; Partitioning**<br>Indexing: Improves query speed by organizing data efficiently (like an index in a book).<br>Partitioning: Splits large databases into smaller pieces for faster access.<br>✅ Example: A bank may partition data by region to speed up account lookups.</p><p>5️⃣** Master-Slave Architecture &amp; Sharding**<br>Master-Slave: One master database handles writes, multiple slaves handle reads (good for read-heavy systems).<br>Sharding: Splits data across multiple databases to balance load and improve performance.<br>✅ Example: Instagram uses sharding to store user data efficiently.</p><p>6️⃣ **SQL vs. NoSQL Databases**<br>SQL (Structured Query Language): Uses tables and is best for structured data (e.g., MySQL, PostgreSQL).<br>NoSQL (Not Only SQL): Handles unstructured data, scalable (e.g., MongoDB, Cassandra).<br>✅ Choosing the right database depends on the use case.</p><p>7️⃣ **Microservices**<br>Instead of having one big application (monolith), microservices break it into smaller, independent services.</p><p>✅ Example: In an e-commerce site, one microservice handles payments, another manages orders, and another tracks inventory.</p><p>8️⃣ **Load Balancing**<br>Distributes traffic across multiple servers to prevent overload and ensure high availability.</p><p>✅ Example: Amazon Web Services (AWS) uses load balancers to handle millions of users at the same time.</p><p>9️⃣ **Caching**<br>Stores frequently accessed data in memory to speed up responses and reduce database load.</p><p>✅ Example: Netflix caches movie recommendations so they load instantly.</p><p>🔟 **Blob Storage**<br>Used for storing large files like images, videos, and documents.</p><p>✅ Example: Google Drive and Dropbox store user files using blob storage.</p><p>1️⃣1️⃣ **Content Delivery Networks (CDN)**<br>CDNs cache content closer to users to reduce loading time.</p><p>✅ Example: YouTube stores copies of videos in different regions to improve streaming speed.</p><p>1️⃣2️⃣ **CAP Theorem**<br>In distributed systems, you can only guarantee two out of three:<br>✔ Consistency (data is the same everywhere)<br>✔ Availability (system is always accessible)<br>✔ Partition Tolerance (system continues working even if parts fail)</p><p>✅ Example: Banks prioritize consistency, while social media prioritizes availability.</p><p>1️⃣3️⃣ **Asynchronous Writing &amp; LSM Tree Databases**<br>Asynchronous Writing: Speeds up write-heavy operations by writing in the background.<br>LSM Tree Databases: Designed for fast writes (e.g., LevelDB, RocksDB).<br>✅ Example: WhatsApp uses LSM tree databases to handle billions of messages daily.</p><p>1️⃣4️⃣ **Database Replication &amp; High Availability**<br>Replication ensures a backup copy of the database exists to prevent data loss and downtime.</p><p>✅ Example: Google Cloud replicates data across multiple regions for reliability.</p><p>1️⃣5️⃣ **Effective Monitoring**<br>Monitoring tools track performance and detect failures to keep a system running smoothly.</p><p>✅ Example: Netflix uses real-time monitoring to fix issues before they affect users.</p><p>**Final Thoughts**<br>Mastering system design concepts is crucial for software engineers. You can build scalable, reliable, and high-performance systems by understanding these principles.</p><p>🚀 Keep learning, keep designing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fed519f06ba2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Java Developer’s Checklist for SOLID Principles, OOP, and Design Patterns]]></title>
            <link>https://medium.com/@rajendersingh.1193/java-developers-checklist-for-solid-principles-oop-and-design-patterns-72c1f97f923e?source=rss-5df8667e2ab0------2</link>
            <guid isPermaLink="false">https://medium.com/p/72c1f97f923e</guid>
            <dc:creator><![CDATA[Rajender Singh ]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 09:07:38 GMT</pubDate>
            <atom:updated>2025-06-12T09:07:38.251Z</atom:updated>
            <content:encoded><![CDATA[<p>Writing clean, scalable, and maintainable Java code isn’t just about syntax — it’s about design. Whether a beginner or a senior developer, here’s a practical checklist to validate that your code follows proper <strong>SOLID principles</strong>, <strong>OOP design</strong>, and uses appropriate <strong>design patterns</strong>.</p><h3>✅ SOLID Principles Checklist</h3><h3>🔹 S — Single Responsibility Principle (SRP)</h3><ul><li>Does this class have <strong>only one reason to change</strong>?</li><li>Are you separating business logic, data access, and presentation logic?</li><li>Are utility/helper functions moved into their own classes?</li></ul><h3>🔹 O — Open/Closed Principle (OCP)</h3><ul><li>Can new behavior be added by <strong>extending</strong> the class, not modifying it?</li><li>Are you using inheritance, interfaces, or polymorphism to achieve extensibility?</li><li>Are patterns like <strong>Strategy</strong>, <strong>Decorator</strong>, or <strong>Factory</strong> used where relevant?</li></ul><h3>🔹 L — Liskov Substitution Principle (LSP)</h3><ul><li>Can any subclass <strong>replace the parent class</strong> without breaking behavior?</li><li>Do overridden methods <strong>respect expected behavior</strong> and contracts?</li><li>Are exceptions thrown in subclasses <strong>compatible with parent contracts</strong>?</li></ul><h3>🔹 I — Interface Segregation Principle (ISP)</h3><ul><li>Are interfaces <strong>small and specific</strong> to the implementing class?</li><li>Are classes <strong>not forced to implement unused methods</strong>?</li><li>Do you split large interfaces into <strong>role-specific interfaces</strong>?</li></ul><h3>🔹 D — Dependency Inversion Principle (DIP)</h3><ul><li>Do high-level classes <strong>depend on interfaces</strong>, not concrete classes?</li><li>Are dependencies injected via the <strong>constructor or framework (e.g., Spring)</strong>?</li><li>Are you avoiding tight coupling by using abstractions?</li></ul><h3>🧩 OOP Best Practices Checklist</h3><ul><li>Are you using <strong>encapsulation</strong> (private fields + public getters/setters)?</li><li>Is <strong>inheritance</strong> used carefully, and only when “is-a” truly applies?</li><li>Are you applying <strong>composition over inheritance</strong> where appropriate?</li><li>Are you avoiding <strong>God Objects</strong> (classes that do too much)?</li><li>Are method lengths and class responsibilities kept minimal?</li></ul><h3>🔁 Design Patterns Awareness</h3><ul><li>Is there a clear use of common patterns like <strong>Factory</strong>, <strong>Builder</strong>, <strong>Observer</strong>, <strong>Strategy</strong>, etc.?</li><li>Are design patterns used for <strong>solving recurring design problems</strong>, not for over-engineering?</li><li>Is each pattern documented in code using comments or naming conventions?</li></ul><pre>// Example: Strategy Pattern for dynamic pricing<br>public interface PricingStrategy {<br>    double calculatePrice(Product product);<br>}</pre><h3>📊 Architectural Integrity (Advanced but Recommended)</h3><h3>Use tools like:</h3><ul><li>✅ <strong>SonarQube</strong>: to detect complexity, duplication, and bad practices</li><li>✅ <strong>ArchUnit</strong>: to write architecture validation tests</li><li>✅ <strong>Checkstyle</strong>: to enforce coding conventions</li><li>✅ <strong>IntelliJ Metrics Plugin</strong>: to measure class/method size, cohesion, etc.</li></ul><h3>🧪 Testing as an Indicator of Design</h3><ul><li>Can you easily write <strong>unit tests</strong> for your classes?</li><li>Is mocking difficult due to <strong>tight coupling</strong> or <strong>static methods</strong>?</li><li>Does your design allow for the <strong>inversion of control</strong> and <strong>testability</strong>?</li></ul><h3>🚀 Final Words</h3><p>This checklist is not a one-time audit — it’s a mindset. Apply it during:</p><ul><li>Code reviews</li><li>Refactoring</li><li>Architectural design</li><li>Writing new modules</li></ul><p>Start small, use tools where necessary, and make <strong>clean code your habit</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72c1f97f923e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>