How do I print my name (Simron) 1000 times in Java without looping?

1 votes
124 views
simron shukla asked 11-Mar-2018 in programming by simron shukla
How do I print my name (Simron) 1000 times in Java without looping?


1 Answer

0 votes
Arti Mishra answered 02-Apr-2018 by Arti Mishra
*JAVA Code Queries*

Well, writing down the "Simron" a thousand times in JAVA without using Loops is not a big deal...
So here you go with the related code that could solve your queries within seconds:

public class PrintName {
 public static void main(String[] args) {
  printName();
 }
   int nextNumber = 0;  private static void printName() {   if(nextNumber < 1000)    {    System.out.println("Simron");    nextNumber++;    printName();   //Note: calls printName() method again    }   else {    System.exit(0);    }  }  }

Hope this had been a help to you!