class WrongNumberException extends Exception { WrongNumberException(String msg) { super(msg); } } class Calculate { private int kerSzam() { return -9; } public void calc() throws WrongNumberException { int szam = kerSzam(); if(szam<=0) throw new WrongNumberException("Hiba! Nem megfelelő szám!"); else System.out.println("A szam: " + szam); } } class App { public static void main(String args[]) throws Exception { new Calculate().calc(); } }