Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions