Write a program in a class named Shining that prints the following line of outpu
ID: 3644609 • Letter: W
Question
Write a program in a class named Shining that prints the following line of output 1000 times:All work and no play makes Jack a dull boy.
You should not write a program whose source code is 1000 lines long; use methods to shorten the program. What is the shortest program you can write that will produce the 1000 lines of output, using only the material from Chapter 1 (println, methods, etc.)?
Explanation / Answer
class Hundred{ static int i=0; void func() { i++; if(i>1000) return; else{System.out.println("Sentence "); func(); }} public static void main(String args[]) { func(); }} Just execute this code u will get the desired result.. But be sure that your JVM should support Stack to 1000 times. Otherwise it will show java.lang.StackOverFlowError
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.