javaloops

Execute a command X times


How to execute a command multiple times?

for example this code

System.out.println("Hello World!");

I want to run it 500 times. How do i do it ?


Solution

  • Use a loop,

    for(int i = 0; i < 500; ++i)
        System.out.println("Hello World!");
    

    Please go through a basic Java tutorial. One can be found here