<?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>DEV Community: Cal Afun</title>
    <description>The latest articles on DEV Community by Cal Afun (@cal_afun_2475adb4b562023b).</description>
    <link>https://dev.to/cal_afun_2475adb4b562023b</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%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png</url>
      <title>DEV Community: Cal Afun</title>
      <link>https://dev.to/cal_afun_2475adb4b562023b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cal_afun_2475adb4b562023b"/>
    <language>en</language>
    <item>
      <title>What I Did on Day Two of Building My Study Buddy AI</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Sat, 30 Aug 2025 09:46:13 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/what-i-did-on-day-two-of-building-my-study-buddy-ai-28m1</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/what-i-did-on-day-two-of-building-my-study-buddy-ai-28m1</guid>
      <description>&lt;p&gt;On Day One, I set up the database that will hold everything my Study Buddy needs to remember (courses, materials, struggles, questions, etc.).&lt;br&gt;
Today, I made the database come alive. I can now add and fetch real information like my courses and weekly materials.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adding Courses
A course is basically the subject I’m studying (Math, Physics, CS…). I wrote a function that lets me save a new course into the database:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_course(name):
    conn = sqlite3.connect("database.db")
    c = conn.cursor()
    c.execute("INSERT INTO courses (name) VALUES (?)", (name,))
    conn.commit()
    conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;When I run add_course("Physics"), it saves Physics into my database.&lt;/p&gt;

&lt;p&gt;Adding Weekly Materials&lt;br&gt;
Next, I wanted to keep track of what I study each week. For that, I created add_material:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_material(course_id, week, content):
    conn = sqlite3.connect("database.db")
    c = conn.cursor()
    c.execute(
        "INSERT INTO materials (course_id, week, content) VALUES (?, ?, ?)",
        (course_id, week, content)
    )
    conn.commit()
    conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I can do things like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_material(1, 1, "Week 1 - Algebra Notes")
add_material(2, 1, "Week 1 - Intro to Programming PDF")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fetching Courses &amp;amp; Materials&lt;br&gt;
To confirm things are working, I also wrote simple functions to list out what’s stored:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Courses:", get_courses())
print("Materials for Physics:", get_materials(1))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Courses: [(1, 'Mathematics'), (2, 'Physics'), (3, 'Computer Science')]
Materials for Physics: [(1, 1, 'Week 1 - Algebra Notes')]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I Learned&lt;br&gt;
How to insert and fetch data from a SQLite database.&lt;br&gt;
The importance of creating small helper functions (add_course, add_material) to keep my project clean and reusable.&lt;br&gt;
My Study Buddy can now track multiple subjects and the weekly notes I upload.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day One of Building My AI Study Buddy with Python + SQLite</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Sat, 30 Aug 2025 09:25:45 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/day-one-of-building-my-ai-study-buddy-with-python-sqlite-5h1b</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/day-one-of-building-my-ai-study-buddy-with-python-sqlite-5h1b</guid>
      <description>&lt;p&gt;What I Did on Day One of Building My Study Buddy AI&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Created a Database
Every app that needs to remember things needs a database. In my case, I want my AI Study Buddy to:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Store my courses (Math, Physics, etc.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Store materials I upload weekly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep track of my struggles (things I find difficult).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save questions + answers (so it can test me later).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Record my calendar events (like midsems).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Wrote Python Code to Create Tables
I used sqlite3 (Python’s built-in database library) to create the database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s what each table does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;courses → list of all my subjects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;materials → weekly content I upload.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;struggles → what I find hard that week.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;questions → AI-generated or manual test questions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;answers → my answers and whether they were correct.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;calendar → my upcoming academic events.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of tables as Excel sheets, but inside Python.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inserted My First Course
I tested the database by inserting "Mathematics" into the courses table.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;c.execute("INSERT INTO courses (name) VALUES (?)", ("Mathematics",))&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This means:&lt;br&gt;
&lt;code&gt;INSERT INTO courses (name)&lt;/code&gt; → I’m filling the column name in the courses table.&lt;br&gt;
&lt;code&gt;VALUES (?)&lt;/code&gt; → The ? is a placeholder for safe input.&lt;br&gt;
&lt;code&gt;("Mathematics",)&lt;/code&gt; → The actual value to insert.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetched My First Row
Then I asked the database:
&lt;code&gt;c.execute("SELECT * FROM courses")&lt;/code&gt;
&lt;code&gt;print("Courses:", c.fetchall())&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM courses&lt;/code&gt; → Get everything from the courses table.&lt;br&gt;
&lt;code&gt;fetchall()&lt;/code&gt; → Collect all rows into Python.&lt;br&gt;
&lt;code&gt;print(...)&lt;/code&gt; → Show results.&lt;/p&gt;

&lt;p&gt;Output looked like:&lt;br&gt;
Courses: [(1, 'Mathematics')]&lt;br&gt;
1 = the ID (auto-assigned by database).&lt;br&gt;
'Mathematics' = the course name.&lt;br&gt;
So now my Study Buddy officially knows I have a Math course&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Guys share your stories</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Fri, 29 Aug 2025 20:02:49 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/guys-share-your-stories-467j</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/guys-share-your-stories-467j</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/cal_afun_2475adb4b562023b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png" alt="cal_afun_2475adb4b562023b"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/cal_afun_2475adb4b562023b/whats-your-funniest-or-worst-debugging-war-story-3kik" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;What’s Your Funniest (or Worst) Debugging War Story?&lt;/h2&gt;
      &lt;h3&gt;Cal Afun ・ Aug 29&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Fri, 29 Aug 2025 18:32:09 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/-3lmm</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/-3lmm</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/cal_afun_2475adb4b562023b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png" alt="cal_afun_2475adb4b562023b"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/cal_afun_2475adb4b562023b/guys-lets-share-our-stories-3h3m" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Guys let's share our stories😩&lt;/h2&gt;
      &lt;h3&gt;Cal Afun ・ Aug 29&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Guys let's share our stories😩</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Fri, 29 Aug 2025 18:31:56 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/guys-lets-share-our-stories-3h3m</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/guys-lets-share-our-stories-3h3m</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/cal_afun_2475adb4b562023b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png" alt="cal_afun_2475adb4b562023b"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/cal_afun_2475adb4b562023b/whats-your-funniest-or-worst-debugging-war-story-3kik" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;What’s Your Funniest (or Worst) Debugging War Story?&lt;/h2&gt;
      &lt;h3&gt;Cal Afun ・ Aug 29&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>discuss</category>
      <category>debugging</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What’s Your Funniest (or Worst) Debugging War Story?</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Fri, 29 Aug 2025 18:31:25 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/whats-your-funniest-or-worst-debugging-war-story-3kik</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/whats-your-funniest-or-worst-debugging-war-story-3kik</guid>
      <description>&lt;p&gt;We’ve all been there. You’re staring at your code, convinced everything is fine, yet somehow the program refuses to cooperate.&lt;br&gt;
Maybe it was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A missing semicolon that stole hours of your life.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A variable named l (lowercase L) that looked exactly like 1 (the number one).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Or that one time you thought the bug was in your code… but it was actually in the API all along.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Debugging is equal parts pain and growth. Every developer has at least one unforgettable debugging “war story.”&lt;/p&gt;

&lt;p&gt;My Debugging Story😭&lt;br&gt;
One time, I spent half a day trying to figure out why my Python script wasn’t printing anything. Turns out I had saved the file as math.py and shadowed Python’s built-in math library. The moment I renamed it, everything worked. 😅&lt;/p&gt;

&lt;p&gt;Your Turn&lt;br&gt;
I want to hear your story!&lt;br&gt;
🧐What’s the funniest, strangest, or most frustrating bug you’ve ever debugged?&lt;br&gt;
Share it in the comments below. Feel free to drop a code snippet if it makes the story funnier!&lt;br&gt;
I’ll feature the most interesting stories in a future blog post (with credits, of course 🎉).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Matters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Debugging is how we all grow as developers. By sharing stories, we:&lt;br&gt;
Learn new debugging tricks.&lt;br&gt;
Realize we’re not alone in our struggles.&lt;br&gt;
Laugh at the chaos of programming.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Bitwise Operators In Java</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Thu, 28 Aug 2025 17:59:42 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/understanding-bitwise-operators-in-java-1a0n</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/understanding-bitwise-operators-in-java-1a0n</guid>
      <description>&lt;p&gt;Before we dive deep into today's blog, I want us to talk about what bits are. Bits are the smallest piece of information a computer understands. Bits only have 2 values; 0 or 1.&lt;br&gt;
0 usually meaning off or false&lt;br&gt;
1 usually meaning on or true&lt;/p&gt;

&lt;p&gt;Computers represent everything from symbols to text and numbers with 0's and 1's, and a combination of these 0's and 1's forms a binary number.&lt;br&gt;
For example; the decimal number 5 is just a 101 in binary and this is 3 bits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bitwise Operators
&lt;/h2&gt;

&lt;p&gt;Bitwise operators allow you to work directly with the individual bits inside the integer. Java provides; AND(&amp;amp;), OR(|), XOR(6^), NOT(~).&lt;br&gt;
These operators allow us to work directly with the binary representation of numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bitwise Shift Operators
&lt;/h2&gt;

&lt;p&gt;When working with bits in programming, two operators you’ll often encounter are &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; (left shift) and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; (right shift). At first, they may look a little intimidating, but once you get the intuition, they’re actually very powerful and surprisingly easy to understand. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Left Shift Operator &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;
Think of the &amp;lt;&amp;lt; operator as pushing all the bits in a number to the left, and filling the empty spaces on the right with zeros.
Example:
&lt;code&gt;int x = 5 &amp;lt;&amp;lt; 1;&lt;/code&gt;
5 in binary = 0101
Shift left by 1 → 1010
Result = 10&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Intuition:&lt;br&gt;
Each left shift is the same as multiplying by 2:&lt;br&gt;
5 &amp;lt;&amp;lt; 1 = 5 × 2 = 10&lt;br&gt;
5 &amp;lt;&amp;lt; 2 = 5 × 4 = 20&lt;br&gt;
So, &amp;lt;&amp;lt; is basically a fast way to multiply numbers by powers of 2.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Right Shift Operator &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;
The &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; operator works the opposite way: it pushes all the bits in a number to the right, filling the empty spaces on the left with either zeros or the sign bit (depending on the language and whether the number is positive or negative).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;code&gt;int y = 20 &amp;gt;&amp;gt; 1;&lt;/code&gt;&lt;br&gt;
20 in binary = 10100&lt;br&gt;
Shift right by 1 → 01010&lt;br&gt;
Result = 10&lt;br&gt;
Intuition:&lt;br&gt;
Each right shift is the same as dividing by 2 (ignoring remainders):&lt;br&gt;
20 &amp;gt;&amp;gt; 1 = 20 ÷ 2 = 10&lt;br&gt;
20 &amp;gt;&amp;gt; 2 = 20 ÷ 4 = 5&lt;br&gt;
So, &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is like a quick way to divide numbers by powers of 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Are Shifts Useful?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Bit masking&lt;/strong&gt; – Used to check or manipulate specific bits in a number.&lt;br&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt; – Shifts can multiply or divide by 2 much faster than arithmetic operations.&lt;br&gt;
&lt;strong&gt;Low-level programming&lt;/strong&gt; – Essential in hardware control, graphics, compression, and cryptography.&lt;/p&gt;

&lt;p&gt;Quick Intuition Recap&lt;br&gt;
x &amp;lt;&amp;lt; n → Shift left → Multiply by 2^n&lt;br&gt;
x &amp;gt;&amp;gt; n → Shift right → Divide by 2^n&lt;/p&gt;

&lt;p&gt;Once you see shift operators as shortcuts for multiplying and dividing by powers of two, they stop being scary and start becoming powerful tools. Whether you’re doing system programming, optimizing code, or just learning about bits, &amp;lt;&amp;lt; and &amp;gt;&amp;gt; will show up everywhere.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Sat, 23 Aug 2025 22:40:50 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/-3kkk</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/-3kkk</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/cal_afun_2475adb4b562023b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png" alt="cal_afun_2475adb4b562023b"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/cal_afun_2475adb4b562023b/the-highest-score-is-currently-1635-think-you-can-beat-that-bring-the-game-on-5f15" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;The highest score is currently 16/35😱. Think you can beat that? Bring the game on!!&lt;/h2&gt;
      &lt;h3&gt;Cal Afun ・ Aug 21&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#discuss&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>java</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Check out this piece on information on java☺️</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Sat, 23 Aug 2025 22:39:46 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/check-out-this-piece-on-information-on-java-259e</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/check-out-this-piece-on-information-on-java-259e</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/cal_afun_2475adb4b562023b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png" alt="cal_afun_2475adb4b562023b"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/cal_afun_2475adb4b562023b/input-and-output-in-java-29p1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Input and Output in Java&lt;/h2&gt;
      &lt;h3&gt;Cal Afun ・ Aug 23&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>programming</category>
      <category>java</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Input and Output in Java</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Sat, 23 Aug 2025 22:37:42 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/input-and-output-in-java-29p1</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/input-and-output-in-java-29p1</guid>
      <description>&lt;p&gt;In Java, input and output (I/O) are how a program interacts with the outside world. Most beginner programs use the console, a simple text interface, to read input from users and display output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Printing Output&lt;/strong&gt;&lt;br&gt;
Printing messages to the console is straightforward using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("Hello, world!");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints the text but is followed by a newline. If you do not want it to create a new line at the end, then use;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.print("Hello, ");
System.out.print("world!");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reading Input&lt;/strong&gt;&lt;br&gt;
Reading input from the user is slightly more involved. Java provides the Scanner class for this purpose, which can read text, numbers, and more from the console.&lt;/p&gt;

&lt;p&gt;First, you need to import the class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Scanner;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you create a Scanner object attached to System.in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scanner in = new Scanner(System.in);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reading a string&lt;br&gt;
If the input may contain spaces, use nextLine():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.print("What is your name? ");
String name = in.nextLine();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a single word (no spaces), use next():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.print("Enter your first name: ");
String firstName = in.next();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reading Numbers&lt;/strong&gt;&lt;br&gt;
To read integers or floating-point numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.print("How old are you? ");
int age = in.nextInt();

System.out.print("Enter your height in meters: ");
double height = in.nextDouble();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Scanner is a class
In Java, a class is like a blueprint for creating objects. The Scanner class is defined in the java.util package, and it provides methods to read input from different sources—like the console, files, or strings.
When you do:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scanner in = new Scanner(System.in);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are creating a Scanner object called in. Think of it like saying:&lt;br&gt;
“I want a tool (Scanner object) that can read input, and I’ll attach it to this input source (System.in).”&lt;/p&gt;

&lt;p&gt;_An input stream in Java is basically a channel through which data flows into your program. Think of it like a pipe that carries information from some source (keyboard, file, network, etc.) into your program so it can be read and processed.&lt;br&gt;
_&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System.in is an InputStream&lt;/strong&gt;&lt;br&gt;
System is a built-in class in Java (in the java.lang package, so you don’t need to import it).&lt;br&gt;
in is a static member (variable) of the System class. Its type is InputStream.&lt;br&gt;
InputStream represents a source of bytes—here, it’s the console (keyboard input).&lt;br&gt;
So when you pass System.in to the Scanner constructor, you’re telling the Scanner:&lt;br&gt;
“Read the bytes that come from the console and let me interpret them as text, numbers, etc.”&lt;/p&gt;
&lt;h2&gt;
  
  
  Collecting Sensitive Input (Passwords) in Java
&lt;/h2&gt;

&lt;p&gt;When reading input from users, sometimes the data is sensitive, like passwords. Using Scanner isn’t safe for this, because the input appears plainly on the console as the user types. To handle this securely, Java provides the Console class.&lt;/p&gt;

&lt;p&gt;Using the Console Class&lt;br&gt;
&lt;code&gt;import java.io.Console&lt;/code&gt;&lt;br&gt;
You can get a Console object like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Console cons = System.console();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have a Console, you can read input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Read username
String username = cons.readLine("User name: ");

// Read password securely
char[] passwd = cons.readPassword("Password: ");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why char[] Instead of String?&lt;br&gt;
Passwords are returned as character arrays rather than strings for security reasons:&lt;br&gt;
Strings in Java are immutable, so they stay in memory until garbage-collected.&lt;br&gt;
Character arrays can be overwritten immediately after use to reduce the risk of exposure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Overwrite the password array after processing
for (int i = 0; i &amp;lt; passwd.length; i++) {
    passwd[i] = '*';
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key Points&lt;br&gt;
Console input is line-based, unlike Scanner.&lt;br&gt;
There are no methods to read individual words or numbers—you read one line at a time.&lt;br&gt;
Always process sensitive data carefully and clear it from memory when done.&lt;/p&gt;

&lt;p&gt;Tips: If you run your Java program in some IDEs (like Eclipse or IntelliJ), System.console() may return null. For secure password input, run your program in a terminal or command prompt.&lt;/p&gt;

&lt;p&gt;Example code;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.io.Console;

public  class proto{
    public static void main(String [] args){
        Console cons = System.console();

        if (cons == null){
            System.out.println("No console available, try in terminal");
            return;
        }

        String username = cons.readLine("Username: ");
        char[] password = cons.readPassword("Password: ");

        System.out.println("Welcome, " + username + "!");
        for (int i = 0; i &amp;lt; password.length; i++) { // pver here we use indices so it could also be for(int i = 0; i &amp;lt;= password.length-1; i++)
            password[i] = '*';  // Overwrite each character
        }

    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tips &amp;amp; FAQs: Understanding Console Input and Passwords in Java&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why don’t we use Scanner for passwords?
Scanner shows everything typed on the console, which is insecure for passwords.
Use Console.readPassword() to hide input.&lt;/li&gt;
&lt;li&gt;Why is System.console() sometimes null?
System.console() only works in real terminals (macOS Terminal, Windows CMD, Linux shell).
Some IDEs like Eclipse, IntelliJ, or VS Code use an internal console that isn’t a full terminal.
Always check for null before using Console to avoid crashes&lt;/li&gt;
&lt;li&gt;Why do we use char[] for passwords instead of String?
Strings are immutable; they remain in memory until garbage-collected.
char[] can be overwritten immediately to reduce the risk of exposing passwords.&lt;/li&gt;
&lt;li&gt;Why do we overwrite the password array after use?
Overwriting ensures sensitive data does not stay in memory.
You still can log in again—the source of truth (like a database) still stores the password.
For example;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; password.length; i++) {
    password[i] = '*';
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Why is there a return in the null check?
return exits the main method early if the console is not available.
Prevents a NullPointerException if you try to use cons later.&lt;/li&gt;
&lt;li&gt;Why is char[] used instead of a single char?
char[] is an array of characters, representing the full password.
Allows you to overwrite each character after processing for security.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding Type Casting in Java</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Fri, 22 Aug 2025 17:46:04 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/understanding-type-casting-in-java-65l</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/understanding-type-casting-in-java-65l</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In Java, different data types occupy varying amounts of memory. Sometimes, you may need to convert one type to another.For example, from a &lt;code&gt;double&lt;/code&gt; to an &lt;code&gt;int&lt;/code&gt;, or from an &lt;code&gt;int&lt;/code&gt; to a &lt;code&gt;double&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This process is called &lt;code&gt;type casting&lt;/code&gt;. Casting allows us to explicitly control how values are converted between data types&lt;/p&gt;

&lt;h2&gt;
  
  
  Types Of Casting
&lt;/h2&gt;

&lt;p&gt;There are two main types of casting in Java. They are: Widening Casting (Automatic / Implicit) and Narrowing Casting (Explicit / Manual)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Widening Casting(Automatic/Implicit)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is used when you are casting a smaller data type to a larger data type. With this type, no data will be lost from the conversion. Example changing an &lt;code&gt;int&lt;/code&gt; to a &lt;code&gt;double&lt;/code&gt;. For example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int myInt = 10;
double myDouble = myInt; // Automatic conversion
System.out.println(myDouble); // Output: 10.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Narrowing Casting (Explicit / Manual)
&lt;/h2&gt;

&lt;p&gt;This is used when you are changing a larger data type to a smaller data type. This is riskier because data loss is more probable here. An example is changing &lt;code&gt;double&lt;/code&gt; to &lt;code&gt;int&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double x = 9.997;
int nx = (int) x; // Explicit cast
System.out.println(nx); // Output: 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Notice how 9.997 becomes 9. This is because the decimal part is discarded.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Casting and Rounding
&lt;/h2&gt;

&lt;p&gt;What if you don’t want to just throw away the decimal part?&lt;br&gt;
That’s where Math.round() comes in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double x = 9.997;
int nx = (int) Math.round(x); // Round to nearest int
System.out.println(nx); // Output: 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Math.round() returns a long. That’s why we add (int) to cast it back to int.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example&lt;/strong&gt;&lt;br&gt;
Imagine you’re building a program that compares floating-point numbers up to 3 decimal places:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double num1 = 25.586;
double num2 = 25.589;

int n1 = (int)(num1 * 1000); // Casting after scaling
int n2 = (int)(num2 * 1000);

if (n1 == n2) {
    System.out.println("They are the same up to 3 decimal places");
} else {
    System.out.println("They are different");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Could you beat the high score (16/35)😨</title>
      <dc:creator>Cal Afun</dc:creator>
      <pubDate>Thu, 21 Aug 2025 20:52:39 +0000</pubDate>
      <link>https://dev.to/cal_afun_2475adb4b562023b/could-you-beat-the-high-score-1635-1a60</link>
      <guid>https://dev.to/cal_afun_2475adb4b562023b/could-you-beat-the-high-score-1635-1a60</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/cal_afun_2475adb4b562023b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3440349%2Fe4f17f3a-b55d-474f-800c-a99ff8b6b962.png" alt="cal_afun_2475adb4b562023b"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/cal_afun_2475adb4b562023b/java-fundamentals-quiz-can-you-get-a-perfect-score-5g97" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Java Fundamentals Quiz — Can You Get a Perfect Score?&lt;/h2&gt;
      &lt;h3&gt;Cal Afun ・ Aug 20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#discuss&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>java</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
