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
Post a Comment