try { double a = be.nextDouble(); } catch (Exception e) { System.out.println("Nem valós szám!"); }