 Here's a flowchart of a while loop. It starts by testing a condition. If the condition is true, we do the loop body, and then we loop back to test the condition again. As long as it's true, we continue to do the loop body and go back to test the condition again. When the condition becomes false, the loop is concluded. Here's how we write this while loop in Java. And here's an example of a program that uses a while. We want to find the value of n for which the sum of squares up to and including n is greater than or equal to 100. Here's the flowchart. We start by setting n and the sum of squares to zero. If the sum of squares is less than 100, we have to add one to n, add n squared to the sum, and then, to see how the loop is progressing, we print them. We loop back to the condition. Eventually, the sum of squares will not be less than 100. We will have achieved our goal and we can print the answer. Here's the Java program. In lines 12 and 13, we initialize our variables. Line 15 begins the while, where we test the condition. The parentheses around the condition are required. By convention, the word while is followed by a space. At the moment, the sum of squares is zero. The condition, zero less than 100, is true. So we do the loop body. n becomes one. Zero plus one times one is one, which becomes our new sum of squares. And to show that the loop is proceeding, we print them out. Java loops back to the condition. One less than 100 is true. We do the loop body again and n becomes two. One plus two times two is five, the new sum of squares. We print them and loop back to the condition yet again. This process continues as long as the sum of squares is less than 100. At some point, the condition will be false. The sum of squares will be greater than or equal to 100. The while loop will conclude and Java continues on lines 21 and 22 to print the answer properly labeled. Let's give ourselves some room to see this in action and run the program. There's the output from inside the loop and there's the answer that we got after the loop was concluded. And that is a while loop in Java.