Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.mycompany.ex21;
- public class Main4 {
- // метод который выбрасывает исключение
- // используем ключевое слово throws
- public static void test() throws Exception{
- System.out.println("test!!!");
- throw new Exception("что то не так!");
- }
- public static void main(String[] args) {
- try {
- //
- test();
- } catch (Exception ex) {
- ex.printStackTrace();
- System.out.println("ex.message=" + ex.getMessage());
- } finally{
- System.out.println("in block!!");
- }
- System.out.println("OK");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement