How to execute 1 command x times in java

With Java 8 Streams you could do it like that

IntStream.range(0, 500).forEach(i -> System.out.println("Hello World!"));

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