Home

Published

- 1 min read

double parse jtextfield

img of double parse jtextfield

The solution for this is noted below

double parse jtextfield

Solution

   public static void main(String[] args) {
    double amount=0.0;
    try {
         amount = Double.parseDouble(txtMonth.getText());
    } catch (Exception e) {
        System.err.println("ups, this was not castable to double");
          amount=-10.0;
    }
    System.out.println("Here is the double: "+ amount);
}

Try other methods by searching on the site. That is if this doesn’t work