About 1,190,000 results
Open links in new tab
  1. Java While Loop - W3Schools

    Loops are handy because they save time, reduce errors, and they make code more readable. The while loop loops through a block of code as long as a specified condition is true: In the example below, the code in the loop will run, over and over again, as long as a …

  2. Java while Loop - GeeksforGeeks

    Nov 11, 2024 · Java while loop is a control flow statement used to execute the block of statements repeatedly until the given condition evaluates to false. Once the condition becomes false, the line immediately after the loop in the program is executed. Let’s go through a simple example of a Java while loop:

  3. Java while loop Examples - Source Code Examples

    Here is a while loop that counts down from 10, printing exactly ten lines of "tick": public class WhileLoopExample { public static void main (String args []) { int n = 10; while (n > 0) { System. …

  4. Java_Examples/while_loop at main · HunarAA/Java_Examples

    import java.util.Scanner; public class whileLoop { public static void main (String [] args) { Scanner scanner = new Scanner (System.in); // TODO: While loop to print numbers from 1 to 5 int j = 1; while (j <= 5) { System.out.println (j); j++; } /* ------------------------------------------------------- */ // TODO: While loop to print e...

  5. Simple while loop Java Example (with video) - Java Code Geeks

    Nov 11, 2012 · With this example we are going to demonstrate how to use a simple while loop Java statement. The while statement continually executes a block of statements while a particular condition is true. In short, to use a simple while loop you should: Create a while statement that evaluates an expression, which must return a boolean value and has a ...

  6. Java While Loop - w3resource

    Aug 19, 2022 · In Java, a while loop consists of the keyword while followed by a Boolean expression within parentheses, followed by the body of the loop, which can be a single statement or a block of statements surrounded by curly braces. You can use a while loop when you need to perform a task a predetermined number of times.

  7. while-loop · GitHub Topics · GitHub

    Nov 7, 2023 · While loop is used to iterate a part of the program repeatedly until the specified Boolean condition is true. As soon as the Boolean condition becomes false, the loop automatically stops. It's a collection of the programs that I did as a part of weekly assignments. This assessment is in the course, which is Software Automation Engineer based.

  8. While Loops in Java | SourceCodester

    May 9, 2015 · While loops allow the programmer to make a function repeat until certain conditions are met. There are two common intended uses for loops. The first is to keep repeating a set of code until the user satisfies the criteria to exit the loop.

  9. Java while Loop - Java Guides

    The while loop in Java is a control flow statement that allows code to be executed repeatedly based on a given boolean condition. The while loop is fundamental for performing repeated tasks and is particularly useful when the number of iterations is not known beforehand.

  10. Java while Loop: A Comprehensive Tutorial with Code Examples

    Oct 8, 2024 · The while loop is a powerful tool for repeating a block of code as long as a condition remains true. Whether you're validating user input, summing numbers, or running complex logic, the while loop provides the flexibility needed to handle various use cases.

  11. Some results have been removed
Refresh