The next exercise demonstrates the use of variables. It prompts for input from the system window and prints what you typed. Compile and Run the activity as before. You will need to click on the console window to enter your name. The third statement prints the string referred to by 'name'.
Variables refer to objects used in a method.
Variable names begin with a letter followed by zero or more letters or digits. Variables may be global variables, method parameters, part variables or local variables. In this example, 'system' is a global variable while 'name' is a local variable. For example, 'name' in the example is a String because it refers to the string returned from 'system input'. If 'name' later refers to another object, that object must be a String as well.