This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
How can I accomplish ignoring "enter" key. Suppose by initializing of my variables "n1, n2, desc" after - - System.out.print("Number 1 :"); - - instead of putting some data first I hit "enter" by accident - I would like my program to continue without throwing an exception. What can I do about it? InputStreamReader reader = new InputStreamReader(System.in); BufferedReader input = new BufferedReader(reader); System.out.print("Number 1 :"); String n1 = input.readLine(); int number1 = Integer.parseInt(n1); System.out.print("Number 2 :"); String n2 = input.readLine(); int number2 = Integer.parseInt(n2); System.out.print("Description :"); String desc = input.readLine(); Thanks