 The exercises in Chapter 1 use Java as a glorified desk calculator to do arithmetic. After you learned arithmetic, you moved up to Algebra where you used variables. In a similar way, we're now going to move from simple calculations in Java to using variables in Java. It's similar but not identical because variables in Java do not work exactly the same as variables do in Algebra. First, we have to declare variables before we can use them. A declaration gives the name of the variable and its data type. Here are two declarations, one for an integer variable named age and another double floating point variable named price. When a numeric variable is declared, you can think of it as an area of memory that has that name for a label. By default, numeric variables are set to zero. You can assign new values to variables. Let's assign a value to age with this statement. The way Java does this is to look at the right-hand side, figure out what it works out to, in this case 23, and then that is stored in the variable on the left-hand side, replacing whatever used to be there. It's also possible to declare a variable and give it a value in one step. In this case, the right-hand side of the equal sign works out to eight and that gets stored in the newly declared variable price. What happens with this assignment statement? We always, always, always start off with the right-hand side and figure out what it works out to. So let's take a piece of scratch paper and figure out what the current value of price is. It's 8.00. We multiply that by 0.05 and end up with a result of 0.40 for the right-hand side. Now and only now do we look at the left-hand side and find that variable tax is to receive that value. To drive home the point that variables in Java don't work like the ones in algebra, let's look at this set of two statements. At the end of the first statement, age has the value 23. Now let's look at that second statement. In algebra, that doesn't make any sense at all. 23 doesn't equal 24, but again, this isn't algebra. Instead, you're going to follow the rule. When you see an equal sign, you're going to pull out a piece of scratch paper and figure out what's on the right-hand side. What's in age right now? It's 23. We take the 23, add one, and the right-hand side works out to 24. Now and only now do I look at the left-hand side and say, who's getting that 24? The answer is age is getting that 24, so age gets 24 and the old value of 23 is replaced. What we've done here, by the way, is called incrementing age. You'll see patterns like this all the time in Java. You read it as x is assigned x plus one, or x becomes x plus one. And again, you'll see this a lot because it's very common to have computers do counting. The moral of the story, whenever you see an equal sign in a Java statement, you read it as variable is assigned value, or variable becomes value, or variable gets value. You go to the right-hand side first and figure out what that value works out to. Once you have it completely worked out, then the variable on the left will get that value.