 Let's look at this program that reads a person's name and their age and gives a greeting based on the name and age. We'll compile it and run it, enter a name and age, and it works great. Now let's change the program to read the age first and then the name. What happens when we run it? Compile and run, and after we enter the age, we don't even get a chance to enter the name. We get hello comma age 54. What went wrong? Why does this happen? To find out, we need to understand how a scanner works. One important term in understanding scanners is white space, defined as any character or series of characters that represent horizontal or vertical space, such as the space bar, tab key, and new line. When you use a scanner to read with next int or next double, it reads up to but not including the next white space character, converts that to a number, and gives it back to you. Next line, however, does something different. It reads up to and including the next new line and returns whatever read without the new line. Now that we have this information, let's see what happens when we read the name first. Next line reads up to and including the new line, which was provided by the enter key, and returns the result without the new line. When it's time to get the age, the scanner waits for you to type the five four and press enter, and next int reads up to but not including the new line, converts that to the integer 54, and returns it into age. Both variables have the correct information in them. Now let's see what happens when we read the integer first. Next int reads up to but not including the new line, converts it to an integer, and gives it back to us. That new line is still unread, which means that when we call next line, it reads everything up to and including that new line, and gives back all of it except the new line. That's the empty string. That's why we never had the opportunity to enter the name. There was already a new line waiting to be read. The problem is that next int doesn't read the new line. We'll solve it by explicitly calling next line to read it. Once we do that, the program should work okay. Let's see what happens after we make this change. Next int reads up to the new line, and assigns it to age. Our new call to next line will eat up the new line character that's left over. There's no assignment here, so the result of this call to next line is discarded. Now there's nothing left in the input stream, so when we encounter another next line, this time the program waits for us to enter the name, and reads up to and including the new line, and returns it without the new line character. And again, both of our variables have the correct information in them. Let's put that change into the program to see that it works. After we call next int, we'll call next line to discard the remaining new line character. We'll compile and run. This time when we enter the age, the program will wait for us to enter the name, and it will work properly. In summary, if your program doesn't let you get input when you try to read with next line, you probably have a new line character left over from a previous next int or next double. Put an extra next line call before the one that isn't working, but don't assign it to a variable, and that will get around most of your problems with scanner.