how to input a string and output it several times in java.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to input a string and output it several times in java..

how to input a string and output it several times in java..

17th Dec 2018, 12:40 PM
Abdul Aziz
6 Answers
+ 14
● U can make use of loop OR recursion 👍 //here is basic Recursion function possible for it : static void method(n,str){ if(n--==0) System.exit(0); System.out.println(str); }
17th Dec 2018, 1:53 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
17th Dec 2018, 12:49 PM
Fabian
Fabian - avatar
+ 3
Prompt the user to input a string and put the print statement inside loop
17th Dec 2018, 12:45 PM
Rishi Anand
Rishi Anand - avatar
+ 3
Ya ..use the Scanner class Scanner input = new Scanner(System.in); String str = input.next()
17th Dec 2018, 12:47 PM
Rishi Anand
Rishi Anand - avatar
+ 2
In addition to Fabian code and if you need full control over input text and number of iteration https://code.sololearn.com/c1cJk2vFH6ZV/?ref=app
17th Dec 2018, 1:23 PM
vlada
+ 1
Can we promt in java..
17th Dec 2018, 12:46 PM
Abdul Aziz