Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

My code is throwing java.util.concurrent.ExecutionException exception. Can someone tell me how can I handle this?

1 Answer

0 votes
by (13.1k points)

You can use exception handling like this:

public void exception1() {

       try {

           //code that throws the exception

       } catch (ExecutionException e) {

           //what to do when it throws the exception

       }

   }

   public void exception2() throws ExecutionException {

       //code that throws the exception

   }

You have to keep the second method (exception2()) inside a try-catch block in your execution.

Want to learn Java? Check out the Java certification from Intellipaat.

Browse Categories

...