Answers for "how to loop java"

6

how to make a loop in java

for (int i = 0; i < 3; i++) {}
Posted by: Guest on January-04-2020
4

for loop java

for(/*index declaration*/int i=0; /*runs as long as this is true*/
   i<=5; /*change number at end of loop*/i++){
doStuff();

}
Posted by: Guest on May-04-2020
0

java for loop

// Example of a for loop in java that will iterate the number of times entered by the user
import java.util.Scanner; // import Scanner class
public class grepperjava {
    public static void main(String[] ARGS)
    {
        System.out.println("\nPlease enter a number, and the loop will iterate input times.");
        int input;
        Scanner var = new Scanner(System.in); // Create scanner object, so user-input may be read
        input = var.nextInt();
        var.close();

        for(int i = 0; i < input; i++)
        {
            System.out.println("This will print " + input + " times");
        }
    }
}
Posted by: Guest on February-11-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language