I assure you all that this is not homework.
I have a combo box:
try {
double input = Double.valueOf(input1.getText());
double output = 0;
My combo box code here:
if (output < 2.50){
answerField.setText("£2.50");
}
else{
answerField.setText("£" + String.valueOf (fmt.format(output)));
catch (Exception e) { JOptionPane.showMessageDialog(this,
"Please enter numbers in the fields.
Numbers are 1 2 3 4 5 etc.",
"Oooops!!!",
JOptionPane.ERROR_MESSAGE);
}
The problem I have is that when I run it like this it won’t work.
if I take the if statement out and leave try catch in, it works
and also if I take the try and catch out it and leave only the if, it also works
When I run it using the above, I get this error:
catch without try
; expected
Can anyone help?
you must close your else bracket, and then your try bracket: