Java display one message five times

Question

We would like to write a program that displays Welcome to demo2s.com five times.

You can use for loop to iterate five times.

Code structure

public class Main {
  public static void main(String[] args) {

      System.out.println("Welcome to demo2s.com");

  }
}




public class Main {
  public static void main(String[] args) {
    for (int i = 0; i < 5; i++) {
      System.out.println("Welcome to demo2s.com");
    }
  }
}



PreviousNext

Related