I am trying to call a custom catch expression
String value1 = side1_tb.getText();
String value2 = side2_tb.getText();
String value3 = side3_tb.getText();
try
{
result_lbl.setText(
actual_triangle.Triangle(
Double.parseDouble(value1),
Double.parseDouble(value2),
Double.parseDouble(value3)));
}
catch (NumberFormatException exe)
{
}
So from the above code you can see that there are three textboxes values are being assigned to a string variables and then I implemented a try and catch method with ‘Numberformatexception’ but in the place of ‘Numberformatexception’ I want to implement a custom exception and this exception will be declared in another class lets call this class EXCEPTIONclass.java and in here I want to create an exception if String values are not being able to parse to double values, which I am trying to achieve in the above code.
Not really sure how to extend the exception class and then declare a new exception.
You could do it as follows:
In your catch block, you would wrap the NumberFormatException as follows: