<?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 Vignesh Ponraj on Medium]]></title>
        <description><![CDATA[Stories by Vignesh Ponraj on Medium]]></description>
        <link>https://medium.com/@vponraj97?source=rss-adb3ef44eaf0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ro30x2uyEMmlZAoR</url>
            <title>Stories by Vignesh Ponraj on Medium</title>
            <link>https://medium.com/@vponraj97?source=rss-adb3ef44eaf0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 22:23:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vponraj97/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[When == Betrays You: The Java String Trap]]></title>
            <link>https://medium.com/@vponraj97/when-betrays-you-the-java-string-trap-d31cfbf905bc?source=rss-adb3ef44eaf0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d31cfbf905bc</guid>
            <category><![CDATA[humor]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vignesh Ponraj]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 01:06:15 GMT</pubDate>
            <atom:updated>2025-06-10T01:10:38.733Z</atom:updated>
            <content:encoded><![CDATA[<p>Why your `if (str == “hello”)` might be leading to unintended consequences</p><h3>Ever Had a Bug That Felt Personal?</h3><p>I was two hours into debugging a feature that <em>should</em> have worked. The logic was tight (or so I thought), and the variables looked correct. But still — no output. Nada.</p><p>I stared at this line for what felt like years:</p><pre>if (userInput == &quot;admin&quot;) {<br>    grantAccess();<br>}</pre><p>And then it hit me: The double equals is not what it seems it is.</p><p>As someone who comes from a Python and JS background, where == works just fine for string comparisons, this felt like betrayal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpAVINDiX0j5nIgEuFQl3A.jpeg" /></figure><h3>What’s the Deal with == vs .equals()?</h3><ul><li>In Java, == checks if <strong>two objects point to the same memory address</strong>.</li><li>.equals() checks if <strong>the contents are the same</strong>.</li></ul><p>So while == is like asking, <em>“Are these two keys literally the same key?”</em>, .equals() is like asking, <em>“Do both these keys open the same lock?”</em></p><pre>String a = new String(&quot;hello&quot;);<br>String b = new String(&quot;hello&quot;);<br><br>System.out.println(a == b);       // false<br>System.out.println(a.equals(b));  // true</pre><p>Lesson? Strings in Java are objects, not primitives. So == won’t do what you think it will unless you really mean to compare references.</p><h3>But Wait, Sometimes == Works?</h3><p>Yes. And that’s what makes it sneaky.</p><p>Java has something called the <strong>String pool</strong>. If you do this:</p><pre>String x = &quot;hello&quot;;<br>String y = &quot;hello&quot;;<br>System.out.println(x == y); // true</pre><p>Java optimizes memory by pointing both x and y to the same pooled “hello” string. So == seems to work.</p><p>But if that string comes from a user input, a file, or the depths of your app’s logic? That pool magic disappears. You’re now comparing apples to… other apples stored in different bins.</p><p>It was this exact trap that snatched quite a few points from me during the <strong>Java Foundations 1Z0–811 certification exam</strong>. Yep, this tiny detail cost me a better score.</p><h3>So What Should You Do?</h3><p>Easy fix: <strong>Always use .equals() when comparing strings for content.</strong></p><p>Bonus tip: Flip the comparison to avoid null pointer issues:</p><pre>if (&quot;admin&quot;.equals(userRole)) {<br>    showSecretDashboard();<br>}</pre><p>This way, even if userRole is null, your app won’t panic and throw something at you. Null safety for the win!</p><h3>Final Tip: Let the Linter Guide You</h3><p>As far as I’ve used, IntelliJ and VS Code, will nudge you if you use == on strings. Listen to them. They’re not nagging, they’re trying to save your code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d31cfbf905bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Var in Java Isn’t Lazy — It’s Just Tidy]]></title>
            <link>https://medium.com/@vponraj97/var-in-java-isnt-lazy-it-s-just-tidy-c19f545ed7a3?source=rss-adb3ef44eaf0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c19f545ed7a3</guid>
            <category><![CDATA[developer-tips]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[code-readability]]></category>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vignesh Ponraj]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 03:01:09 GMT</pubDate>
            <atom:updated>2025-06-02T03:01:09.571Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Var in Java Isn’t Lazy ; It’s Just Tidy</strong></h3><h4>Java’s most misunderstood keyword, and why it’s not the slacker we think it is</h4><p>I remember the first time I saw var in a Java codebase, my brain hit the brakes because this didn’t look like the Java I knew.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vz35ji8zz8WYeeOBwlyW7Q.jpeg" /><figcaption><em>Wait… this is Java. We don’t do that here</em></figcaption></figure><p>See, I’d just spent weeks getting comfortable with Java’s verbose type declarations. Swapping out Map&lt;String, List&lt;User&gt;&gt;with var didn’t feel like the right thing to do according to how I learnt Java. I wasn’t sure I trusted it.</p><p>But I still gave var a shot. And turns out? It’s not lazy. It’s just… clean.</p><h3>So what even is var, really?</h3><p>var in Java is <em>not</em> dynamic typing. It still plays by Java’s strict rules.</p><p>In Java, var is just <strong>type inference</strong>. The compiler still knows the exact type. You just don’t have to spell it out when it’s painfully obvious.</p><pre>var name = &quot;Vignesh&quot;;  // Still a String<br>var count = 42;        // Still an int<br>var users = new ArrayList&lt;User&gt;();  // Still an ArrayList&lt;User&gt;</pre><p>Behind the scenes, nothing’s changed. The compiler reads it like you wrote the full type out loud. The only difference? You saved yourself some wrist work.</p><h3>But is it good clean or suspiciously clean?</h3><p>Let’s go deeper.</p><p>Using var is the same working with Primitives, Objects and even nested generics.</p><pre>var score = getUserScore(user);</pre><p>same as,</p><pre>int score = getUserScore(user);</pre><p>Considering a nested generic :</p><pre>Map&lt;String, List&lt;Map&lt;String, Object&gt;&gt;&gt; data = fetchData();</pre><p>same with var:</p><pre>var data = fetchData(); // *chef’s kiss*</pre><p>It’s like the difference between saying “I’d like a tall iced oat milk latte with two pumps of vanilla” vs. pointing at the menu and going, “That one.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fP56kC28iXe5b8Dxbb4RLA.jpeg" /><figcaption>var being a head turner</figcaption></figure><h3>Where var can backfire</h3><p>Okay, var isn’t perfect. If you overuse it, your code can turn into a game of <em>guess the type</em>.</p><pre>var thing = doStuff();</pre><p>What is thing? Is it a User? A String? Or worse, some mystery object that sounds important but acts like it’s hiding something.</p><p>This is why clean code with var still demands <strong>clear naming</strong>. Using var without context is like having a new mutual friend who never introduces themselves, fine for a while, but eventually, you’re just guessing things about them.</p><h3>Pro tip to take with you</h3><p>Use var when the right-hand side mentions the type already. It’s great for builder patterns, streams, loops, and generic-heavy messes. But if you ever find yourself staring at a var wondering what it really is… just go back to declaring it. It’s not a sin.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c19f545ed7a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>