Advertisement
sergAccount

Untitled

Jul 17th, 2021
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.ex21;
  7.  
  8. import java.util.logging.Level;
  9. import java.util.logging.Logger;
  10.  
  11. public class Main4 {  
  12.     // метод который выбрасывает исключение
  13.     // используем ключевое слово throws
  14.     public static void test() throws Exception{
  15.         System.out.println("test!!!");
  16.     }
  17.    
  18.     public static void main(String[] args) {
  19.         try {
  20.             //
  21.             test();
  22.         } catch (Exception ex) {
  23.             ex.printStackTrace();
  24.             System.out.println("ex.message=" + ex.getMessage());
  25.         }
  26.         System.out.println("OK");
  27.     }    
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement