Better site compare to remaining for java -


how go same statement in java.(if exception arise want execute :: system.out.println("enter initial balance"); statement.

try{                 system.out.println("enter initial balance");     bal=scan.nextdouble();      }    catch(exception e){     system.out.println("enter numbers" );  }   

one possible solution put in while loop , use boolean check exception:

boolean exception;  {     exception = false;     try {         system.out.println("enter initial balance");         bal = scan.nextdouble();     } catch (exception e) {         exception = true;         scan.next(); //discard input     } } while (exception); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -