It is a bug in your code. See Java.util.Scanner.next() Method Example for a example, and Scanner (Java Platform SE 7 ) for a description of the nextLine() method.