Some part of my code is throwing java.util.concurrent.ExecutionException exception. How can I handle this? Can I use throws clause? I am a bit new to java.
If you're looking to handle the exception, things are pretty straightforward.
public void exceptionFix1() {
try {
//code that throws the exception
} catch (ExecutionException e) {
//what to do when it throws the exception
}
}
public void exceptionFix2() throws ExecutionException {
//code that throws the exception
}
Keep in mind that the second example will have to be enclosed in a try-catch
block somewhere up your execution hierarchy.
If you're looking to fix the exception, we'll have to see more of your code.