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