Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Contohtrycatch2;
- import javax.swing.*;
- public class Contohtrycatch2{
- public static void main(String[]args){
- try{
- int bil=Integer.valueOf(JOptionPane.showInputDialog("Input Bil"));
- System.out.println("Nilai Bil = "+bil);
- // System.out.println("Nilai Bil dibagi 0= "+(bill/0));
- }catch(NumberFormatException e){
- System.out.println("Catch 1 : Kesalahan : Input harus numerik \n"+e);
- }catch(ArithmeticException e){
- System.out.println("Catch 2 : Kesalahan : Ada pembagian dengan 0 \n"+e);
- }catch(Exception e){
- System.out.println("Catch 3 : Kesalahan : Input harus numerik \n"+e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement