DEV Community

Charlie Barajas
Charlie Barajas

Posted on

The while loop in Java

I've been taking Codecademy's Introduction to Java course and so far I've really loved the straigtforward and hands-on approach they have to coding. Here's a snippet i wrote using main method.

class Coffee {

public static void main(String[] args) {

// initialize cupsOfCoffee
int cupsOfCoffee = 1;
// add while loop with counter


while (cupsOfCoffee <= 100) {
  cupsOfCoffee++;
  System.out.println("Fry drinks cup of coffee #" + cupsOfCoffee);
}
Enter fullscreen mode Exit fullscreen mode

}

}

Although basic, it builds a strong foundation for their course material, which also includes career paths with ISC2 partnerships and more.

Top comments (0)