Advertisement
Mastercpp

excepciones

Aug 21st, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1.     public static void main(String[] args) {
  2.         Scanner scanner = new Scanner(System.in);
  3.        
  4.         int x;
  5.         System.out.println("Dame un valor numerico:");
  6.         try{
  7.             x=scanner.nextInt();
  8.             System.out.println(x);
  9.         }catch(InputMismatchException e){
  10.  
  11.             System.out.println("No me diste un valor numerico");
  12.         }finally{
  13.             System.out.println("Se termino la ejecucion del programa");
  14.         }      
  15.        
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement