You need to refer to the appropriate API when a method you're using is not achieving the desired results. Read the Scanner API for the next() method. Compare that to the nextLine() method.