Question: I'm attempting to use try, catch, and final blocks in Java programming, but I can't get my code to work without exceptions/errors while using exception

I'm attempting to use try, catch, and final blocks in Java programming, but I can't get my code to work without exceptions/errors while using exception handling statements. Ironic, I know, but can someone please help? Here is my code thus far:

public class exceptionexample{

public static void main(String[] args) {

try {

int a;

a = "Wordnotnumber";

}catch(ExceptionType e1) {

System.out.println( "error1 " );

}catch(ExceptionType e2) {

System.out.println( "error2 " );

}catch(ExceptionType e3) {

System.out.println( "error3 " );

}finally{

int a;

a = 55

System.out.println( a );

}

}

}

I just want it to run successfully... but I'm not sure what a successful output would be at this point!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!