Answers for "forloops java"

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