Variables

Variables can be thought of as little boxes to hold the different things you want to
save for later use.

Creating a variable is a two-step process:

These following examples show how to create several kinds of variables as well as
explaining what becomes of them

bool q;
            creates a variable q that can hold only boolean values
int seven = 7;
            creates a variable seven that can hold only integers, and 
               that has been initialized with a value of 7
string welcome;
welcome = "Welcome to Java 101: an Introduction to Java";
            creates a variable that can hold only strings of 
               charachers, and then initializes it with the string:
               'Welcome to Java 101: an Introduction to Java'

As you have seen, you can give variables the values you want them to hold at the
time you create the variables, or create the variables, and assign values to them later
(you need not assign values to them at all, if you wasn't to create them to give
yourself a way to tell weather or not you have run a subroutine yet, but more on
that later)

Next

Home Page | Table of Contents | Introduction | Programming | Extras