Hour 5. Storing and Changing Information in a Program

In Hour 2, "Writing Your First Program," you used a variable, a special storage place that is designed to hold information. The information stored in variables can be changed as your program runs, which is why they're called variables. Your first program stored a string of text in a variable called greeting. Strings are only one type of information that can be stored in variables. They also can hold characters, integers, floating-point numbers, and other things. During this hour, you'll learn more about using variables in your Java programs, including the following topics:

  • Creating variables
  • The different types of variables
  • Storing values into variables
  • Using variables in mathematical expressions
  • Putting one variable's value into another variable
  • Increasing and decreasing a variable's value