Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. package Contohtrycatch2;
  2.  
  3. import javax.swing.*;
  4. public class Contohtrycatch2{
  5. public static void main(String[]args){
  6. try{
  7. int bil=Integer.valueOf(JOptionPane.showInputDialog("Input Bil"));
  8. System.out.println("Nilai Bil = "+bil);
  9. // System.out.println("Nilai Bil dibagi 0= "+(bill/0));
  10. }catch(NumberFormatException e){
  11. System.out.println("Catch 1 : Kesalahan : Input harus numerik \n"+e);
  12. }catch(ArithmeticException e){
  13. System.out.println("Catch 2 : Kesalahan : Ada pembagian dengan 0 \n"+e);
  14. }catch(Exception e){
  15. System.out.println("Catch 3 : Kesalahan : Input harus numerik \n"+e);
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement