Ask Question
2 November, 06:07

loopCount = 1; while (loopCount < 3) System. out. println ("Hello"); loopCount = loopCount + 1; No output Hello Hello Hello Hello Hello This is an infinite loop

+4
Answers (2)
  1. 2 November, 07:05
    0
    You need to wrap the statements of loop in curly braces {} if the statements are more than one. In your case loopcounter=loopcounter+1 is out of loop

    Explanation:

    / / Do it like this will make it finite loop

    int loopCount = 1

    while (loopCount < 3) {

    System. out. println ("Hello");

    loopCount = loopCount + 1;

    }
  2. 2 November, 08:11
    0
    wrap the statements of loop in curly braces {} if the statements are more than one. In your case loop counter=loopcounter+1 is out of loop If you want a finite loop then here ist is ffit is iisDo it like this will make it finite loop

    int loopCount = 1

    while (loopCount < 3) {

    System. out. println ("Hello");

    loopCount = loopCount + 1;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “loopCount = 1; while (loopCount < 3) System. out. println ("Hello"); loopCount = loopCount + 1; No output Hello Hello Hello Hello Hello ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers