import java.util.Scanner; class InputTypeError extends Exception { private String value; InputTypeError(String value) { this.value = value; } @Override public String toString() { return "Hiba! A megadott érték hibás: " + this.value; } } public class App { public static void main(String[] args) throws InputTypeError { Scanner scanner = new Scanner(System.in); System.out.print("Szám: "); String input = scanner.nextLine(); scanner.close(); if(!input.matches("^[0-9]+$")) { throw new InputTypeError(input); } } }