Day 3 of 30 Days of Java: Learning Loops the Kanye Way!
Yo! Welcome to Day 3! Today, we’re tackling LOOPS, which are like Kanye's speeches🤔; they keep going (but only as long as you want)🎵
1. The "For" Loop – Kanye on Repeat 🎤
Imagine Kanye playing "Stronger" on repeat for a set number of times—that's a for loop! It’s perfect when you know how many times you need to repeat something.
Explaination: Kanye sings "GOAT" 5 times (0 to 4). The loop starts at
i = 0
, stops wheni < 5
, and incrementsi
by 1 after every run.2. The "While" Loop – Kanye's Creative Process 🧠
What if Kanye keeps working on an album until it’s perfect? That’s a while loop it runs as long as the condition is true.
Explaination: Kanye keeps dropping albums until he hits 10 classics. The loop runs while
albums <= 10
.3. "Do-While" Loop – The Encore King
A do-while loop is like Kanye’s encore at a concert. Even if the fans are ready to go home, Kanye’s performing at least one more time.
Explaination: Kanye will perform that encore, even if there’s just one die-hard fan left.
Kanye's Loop Revision:
For loop: Runs a set number of times, like a pre-planned setlist.
While loop: Keeps going until a condition is false, like Kanye in the studio until the track’s perfect.
Do-while loop: Guarantees at least one run, like Kanye’s encore no matter what!
Day 3 Complete! On to Day 4!
Loops might sound technical, but now you’ve learned them the fun way—Kanye style. Stick with me for these 30 days, and soon, your Java skills will be so good, even Kanye might call you a genius.
Now, go make your code loop harder, better, faster, stronger! See you tomorrow! ✌️