Question: I'm currently developing my own calculator and I'm getting an `NumberFormatException` when I press the plus button inside it:-

```
if(e.getSource() == p) {
    String a[] = new String[2];
    double d[] = new double[2]; 
    for(int i =0; i<2; i++) {
        a[i] = tf.getText();
        d[i] = Double.parseDouble(a[i]);
        System.out.println("First array is "+d[i]);
        sum = sum + d[i];
        tf.setText(null);
    }
}

```

I'm not getting what the number format exception is i searched it's telling me that my string is empty but what i need to do now.

[please click here for errors](https://i.stack.imgur.com/MtA7S.png)

Answer: 
You can't parse `+` inside `Double.parseDouble(String string)`

If the string does not contain a parsable double it throw `NumberFormatException`.
This will resolve your problem

```
if(e.getSource() == p) {
    String a[] = new String[2];
    double d[] = new double[2]; 
    for(int i =0; i<2; i++) {
        a[i] = tf.getText();
         if(a[i].contains("[a-zA-Z]+") == false){
           d[i] = Double.parseDouble(a[i]);
           System.out.println("First array is "+d[i]);
           sum = sum + d[i];
           tf.setText(null);
         }

    }
}

```