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

Asked 11-Mar-2018
Viewed 600 times

1

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



1 Answer


0

*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!

Loading...
Ads