Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java loop using input user

import java.util.Scanner;

public class loop {
    public static void main(String[] args) {
        System.out.println("How much do you wanna make loop: "); // asking how many times u wanna loop
        try (Scanner sc = new Scanner(System.in)) {
            int x    = sc.nextInt();
            for (int i = 1; i < x; i++) {   // this code make ur loop starts with 1 and end by ur answer -1.
                System.out.println("loop "+i+" times"); // this will print out ur result
            }
            
            }
        }
    }
 
Comment

PREVIOUS NEXT
Code Example
Java :: login and logout react native and firebase 
Java :: how to print in a new line in java using print 
Java :: como ordenar un arraylist alfabeticamente en java 
Java :: jbutton border size java 
Java :: convert two bytes to int java 
Java :: declare variables java 
Java :: how to find selenium webelement java 
Java :: initialize a new class java 
Java :: java interfce 
Java :: how to go to next iteration of while loop java 
Java :: importing all java libraries 
Java :: java exception 
Java :: how to draw a rectangle in libgdx 
Java :: deserialize date java 
Java :: check if char is a space java 
Java :: how to get 2 decimal places in java 
Java :: how to split string in java android 
Java :: how to count the number of occurrences of an element in a arraylist in java 
Java :: first character string number java 
Java :: Java alt f4 
Java :: How to use java 8 comparator 
Java :: integer palindrome in java 
Java :: Program to remove duplicates in an ArrayList 
Java :: declare bufferedreader java 
Java :: No suitable driver found for jdbc:mysql 
Java :: java map create with values 
Java :: list.of java 
Java :: File Appender log4j2.properties spring 
Java :: java compute sum and average of array elements 
Java :: java 8 stream option 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =