Skip to main content

Primitive Data Types and Variables

Variables are named containers that can store data (for example, a number, a text string, or an object). As you learned earlier in this book, each variable has a name. There are specific rules you must follow when choosing a variable name:

Variable names can include letters of the alphabet, both upper- and lowercase. They can also include the digits 0-9 and the underscore (_) character.

Variable names cannot include spaces or any other punctuation characters.

The first character of the variable name must be either a letter or an underscore.

Variable names are case sensitive-totalnum, Totalnum, and TotalNum are separate variable names.

There is no official limit on the length of variable names, but they must fit within one line.

Using these rules, the following are examples of valid variable names:


Next: SAQ1