JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
https://www.sololearn.com/Discuss/2751099/?ref=app
Request a number from the console until a
valid number is entered
input sample:
aaa
5
*/
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n=0;
do{
System.out.println("insert a integer value");
try{
n = Integer.parseInt(in.nextLine());
break;
}catch(Exception e){
System.out.println("Error - " + e.getMessage());
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run