We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Exception Handling (Try-catch)
Java Exception Handling (Try-catch)
Sort by
recency
|
339 Discussions
|
Please Login in order to post a comment
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}
Scanner in = new Scanner(System.in);
}
Initially in catch block i simply wrote sysout(e); to print exception message.
But one of the test case failed for arithmetic exception so i used ternery operator like below instaed of writing catch block for all exceptions.
public class Solution {
}
Here is java Exception Handlin (Try-catch) solution - https://programmingoneonone.com/hackerrank-java-exception-handling-try-catch-solution.html