Variables

One of the most powerful features of a programming language is the ability to manipulate variables. A variable is a named location that stores a value.
Values are things that can be printed, stored and (as we'll see later) operated on. The strings we have been printing ("Hello, World.", "Goodbye, ", etc.) are values.

To store a value, you have to create a variable. Since the values we want to store are strings, we declare that the new variable is a string:

String bob;

This statement is a declaration, because it declares that the variable named bob has the type String. Each variable has a type that determines what kind of values it can store. For example, the int type can store integers, and the String type can store strings.

Some types begin with a capital letter and some with lower-case. We will learn the significance of this distinction later, but for now you should take care to get it right. There is no such type as Int or string, and the compiler will object if you try to make one up.

To create an integer variable, the syntax is int bob;, where bob is the arbitrary name you made up for the variable. In general, you will want to make up variable names that indicate what you plan to do with the variable. For example, if you saw these variable declarations:

String firstName;
String lastName;
int hour, minute;

you could guess what values would be stored in them. This example also demonstrates the syntax for declaring multiple variables with the same type: hour and second are both integers (int type).