Even number Counter with a do-while loop instead of a while loop - Java Language Basics

Java examples for Language Basics:while

Description

Even number Counter with a do-while loop instead of a while loop

Demo Code

public class Main
{
      public static void main(String[] args)
      {// ww  w  .j  a v  a2s. co  m
            int number = 2;
            do
            {
                 System.out.print(number + " ");
                 number += 2;
            } while (number <= 20);
            System.out.println();
      }
}

Related Tutorials