Parsing an array of comma-numbers obtained from an input dialog
I suggest next way:

    String x = (JOptionPane.showInputDialog(". Each patamater should be separated with a ',' and without spaces. (eg. 1,2,3)") + ",");
    String[] split = x.split(",");
    Double[] z = new Double[split.length];
    int i = 0;
    for (String s : split) {
        if(s.trim().isEmpty()){
            continue;
        }
        try {
            z[i++] = Double.valueOf(s.trim());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }


1)split() instead of loop for ','

2)validate spaces

read more about String class and it's functions.