-11

i want get input user, if it was a bigger than 10 , stop run program

So far, i have this:

int value=sc.nextInt();
if (value>10){
    **Stop running**
}

1 Answers1

3

You just stop the program by adding the line System.exit(0);, like

int value=sc.nextInt();
if (value>10){
    System.exit(0);
}

This terminates the running JVM and — of course — the program running on it.

deHaar
  • 17,687
  • 10
  • 38
  • 51