import java.util.Scanner; public class ConsoleExample{ public static void main(String[] args){ Scanner console = new Scanner( System.in ); // get a String from the user System.out.print("enter a string:"); String input = console.next(); System.out.println(input); // get an int from the user System.out.print("enter an integer:"); try{ int inputInt = console.nextInt(); System.out.println(inputInt); } catch(java.util.InputMismatchException ex){ System.out.println("that was not an integer...."); return; } finally{ System.out.println("ok, we are done!"); } } // main } // ConsoleExample