<?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: Buddika Abeykoon</title>
    <description>The latest articles on Forem by Buddika Abeykoon (@buddika_b).</description>
    <link>https://forem.com/buddika_b</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%2F736353%2F3de32c57-efad-413c-8f11-065b211df81c.jpeg</url>
      <title>Forem: Buddika Abeykoon</title>
      <link>https://forem.com/buddika_b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/buddika_b"/>
    <language>en</language>
    <item>
      <title>Reason Why j is Always 0 in the Output</title>
      <dc:creator>Buddika Abeykoon</dc:creator>
      <pubDate>Tue, 12 May 2026 02:49:05 +0000</pubDate>
      <link>https://forem.com/buddika_b/reason-why-j-is-always-0-in-the-output-764</link>
      <guid>https://forem.com/buddika_b/reason-why-j-is-always-0-in-the-output-764</guid>
      <description>&lt;p&gt;public class Main&lt;br&gt;
{&lt;br&gt;
    public static void main(String[] args) {&lt;br&gt;
        System.out.println("Start\n");&lt;br&gt;
        int k=0;&lt;br&gt;
        System.out.println("k i j");&lt;br&gt;
        for(int i=0; i&amp;lt;10; i++) {&lt;br&gt;
            int j=0;&lt;br&gt;
            System.out.println(k+" "+i+" "+j);&lt;br&gt;
            j++;k++;&lt;br&gt;
        }&lt;br&gt;
        System.out.println("\n\nEnd");&lt;br&gt;
    }&lt;/p&gt;

&lt;h1&gt;
  
  
  }
&lt;/h1&gt;

&lt;p&gt;Start&lt;br&gt;
k i j&lt;br&gt;
0 0 0&lt;br&gt;
1 1 0&lt;br&gt;
2 2 0&lt;br&gt;
3 3 0&lt;br&gt;
4 4 0&lt;br&gt;
5 5 0&lt;br&gt;
6 6 0&lt;br&gt;
7 7 0&lt;br&gt;
8 8 0&lt;br&gt;
9 9 0&lt;br&gt;
End&lt;/p&gt;

&lt;p&gt;j is always printed as 0 because it is declared inside the for loop. Every time the loop runs, a new variable j is created and its value starts again from 0. After printing, j increases by 1 using j++, but when the next loop iteration starts, j is reset back to 0. That is why the output always shows 0 for j.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why This Java Loop Is Not Infinite 🤔</title>
      <dc:creator>Buddika Abeykoon</dc:creator>
      <pubDate>Mon, 11 May 2026 05:31:35 +0000</pubDate>
      <link>https://forem.com/buddika_b/why-this-java-loop-is-not-infinite-51ie</link>
      <guid>https://forem.com/buddika_b/why-this-java-loop-is-not-infinite-51ie</guid>
      <description>&lt;p&gt;public class Main&lt;br&gt;
{&lt;br&gt;
    public static void main(String[] args) {&lt;br&gt;
        System.out.println("Start\n");&lt;br&gt;
        byte i;&lt;br&gt;
        for(i=0; i&amp;lt;10; i--) {&lt;br&gt;
            System.out.print(i+", ");&lt;br&gt;
        }&lt;br&gt;
        System.out.print("\b\b");&lt;br&gt;
        System.out.println("\n\n\"i\" value is "+i+"\n\nEnd");&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Start&lt;/p&gt;

&lt;p&gt;0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, -89, -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, -100, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -117, -118, -119, -120, -121, -122, -123, -124, -125, -126, -127, -128, &lt;/p&gt;

&lt;p&gt;"i" value is 127&lt;/p&gt;

&lt;p&gt;End&lt;/p&gt;

&lt;p&gt;This loop may look like an infinite loop because the value of i keeps decreasing and will always seem to be less than 10. However, the variable i is declared as a byte, and in Java a byte can only store values from -128 to 127. The loop starts from 0 and keeps decrementing until it reaches -128. After that, Java cannot store -129 in a byte, so the value automatically wraps around to 127 due to overflow. Once i becomes 127, the condition i &amp;lt; 10 becomes false, and the loop terminates. That’s why this loop is not infinite.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why Float and Double Outputs Are Different?</title>
      <dc:creator>Buddika Abeykoon</dc:creator>
      <pubDate>Fri, 08 May 2026 08:59:06 +0000</pubDate>
      <link>https://forem.com/buddika_b/why-float-and-double-outputs-are-different-apo</link>
      <guid>https://forem.com/buddika_b/why-float-and-double-outputs-are-different-apo</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;float f = Long.MAX_VALUE;
double d = Long.MAX_VALUE;

System.out.println("Float max value is : "+ f);
System.out.println("Double max value is : "+ d);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;===============================================&lt;br&gt;
Float max value is : 9.223372E18&lt;br&gt;
Double max value is : 9.223372036854776E18&lt;br&gt;
===============================================*/&lt;/p&gt;

&lt;p&gt;When we assign Long.MAX_VALUE to float and double, both try to store a very large number. But float cannot keep many digits accurately, so Java rounds the value and shows a shorter number like 9.223372E18. double has higher precision, so it can store more digits and shows a more accurate value like 9.223372036854776E18. That’s why both outputs are different even though they come from the same value.&lt;/p&gt;

</description>
      <category>java</category>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
