Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java forcing user to input int

boolean badNumber;
Scanner sc = new Scanner(System.in);
do{
  System.out.print("Please print your number: ");
  try{
    int i = sc.nextInt(); 
    System.out.println("Your Number is: " + i);
    badNumber = false;
  }
  catch(Exception e){
    System.out.println("Bad number");
    sc.next();
    badNumber = true
  }
}while(badNumber);
Comment

PREVIOUS NEXT
Code Example
Java :: como limpar a tela do consola no java 
Java :: how to get history stack in android webview 
Java :: matlab leslie eigenvalue java 
Java :: como pegar o valor de um campo de texto swing 
Java :: jbutton 
Sql :: mysql disable safe mode 
Sql :: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 
Sql :: count of tables in database mysql 
Sql :: select not matching data from two tables 
Sql :: find column in all stored procedures sql server 
Sql :: continue in sql 
Sql :: mysql alter column default 
Sql :: check connections to database postgres 
Sql :: oracle show grants on table 
Sql :: oracle create table comment 
Sql :: dbms output 
Sql :: mysql unix timestamp to date 
Sql :: postgres remove database 
Sql :: sql add days to date 
Sql :: mysql select random id from table 
Sql :: mysql change root mysql_native_password 
Sql :: change column names mssql 
Sql :: mysql backup 
Sql :: how to get list of synonyms in oracle 
Sql :: start mysql server mac 
Sql :: mysql slave status 
Sql :: bulk kill mysql processlist 
Sql :: show databases mysql docker 
Sql :: How to fetch data in between startfromdate to starenddate in sql 
Sql :: metasploit start postgresql 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =