You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { int x = scanner.nextInt(); int y = scanner.nextInt(); System.out.println(x/y); } catch (Exception e) { System.out.println(getText(e)); } } private static String getText(Exception e) { return e.toString().contains(": For input") ? e.toString().substring(0, e.toString().indexOf(":")) : e.toString(); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}