The following code should add integers from two JTextFields and display the result in resultJTextField. Find the error(s) in the following code:
```
1 try
2 {
3 int first = Integer.parseInt( firstJTextField.getText() );
4 int second = Integer.parseInt( secondJTextField.getText() );
5 int result = first + second;
6 }
7
8 resultJTextField.setText( String.valueOf( result ) );
9
10 catch()
11 {
12 JOptionPane.showMessageDialog( this,
13 "Please enter valid integers", "Number Format Error",
14 OptionPane.ERROR_MESSAGE );
15 }
```
This code segment has two errors. First, there is a line of code between the try block and the catch block. This line must be moved inside the try block. Second, the catch block is not passed any exceptions to catch. The catch block should have one parameter of type NumberFormatException, because that is the exception that is likely to occur in the try block.
You might also like to view...
Be interested enough in what you are saying that you do not use a(n) ________ voice to deliver the message
Fill in the blank(s) with correct word
The ________ function determines the smallest value within a chosen range of values
Fill in the blank(s) with correct word