Use try catch block - catching NumberFormatException - because String
not containng integer is a something special here.I call it -
"validation of input data".

int ia = 0,ib = 0;
try {
ia = Integer.parseInt(a);
ib = Integer.parseInt(b);
}
catch ( NumberFormatException e ){
    System.out.println("You have to enter an age(positive number
describing Your age");
    System.exit(0);
}

pacior

On Jul 23, 10:10 am, ben <[email protected]> wrote:
> hi guys!!!
>
> i need help in fixing the following errors...
>
> Exception in thread "main" java.lang.NumberFormatException: For input
> string: " "
>         at java.lang.NumberFormatException.forInputString
> (NumberFormatException.java:48)
>         at java.lang.Integer.parseInt(Integer.java:449)
>         at java.lang.Integer.parseInt(Integer.java:499)
>         at InputFromKeyboardJOptionPane.main
> (InputFromKeyboardJOptionPane.java:20)
> Java Result: 1
> BUILD SUCCESSFUL (total time: 0 seconds)
>
> thanks ,
> ben..

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to