I’ve validated that the entered string is a number. while (true) { try { numberOfmiles = Double.parseDouble(JOptionPane.showInputDialog(null," Enter Positive Number")); break; } catch (NumberFormatException nfs) { JOptionPane.showMessageDialog(null, "Please Enter a Positive number"); } } I need to also check that it is a positive number. How would I do that?
The post How can I validate a numeric input in java? appeared first on BlogoSfera.