public class CatchBerurutan {
    static void proses(String teks) {
        System.out.println("memproses \"" + teks + "\"");
        try {
            int nilai = Integer.parseInt(teks.trim());
            System.out.println("  hasil: " + (100 / nilai));
        } catch (NumberFormatException e) {
            System.out.println("  teks bukan angka: " + e.getMessage());
        } catch (ArithmeticException e) {
            System.out.println("  pembagian nol: " + e.getMessage());
        } catch (Exception e) {
            System.out.println("  kegagalan lain: " + e.getClass().getSimpleName());
        }
    }

    public static void main(String[] args) {
        proses("25");
        proses(" abc ");
        proses("0");
        proses(null);
    }
}
