Java’s keywords and reserved words also cannot be used as names. Java’s key- words and reserved words are shown in Figure 4-2. These words have special meaning in the Java language. You may notice familiar words from the SayHello program in Chapter 3: public, class, static, and void. Other words may be unex- pected, such as new, this, and continue. Figure 4-3 shows examples of valid and invalid identifiers. Data Types In addition to naming each piece of data in the program, programmers also need to tell Java the kind of data that will be assigned to the name. The data type is the format in which the data will be stored and the size the variable will be given in memory. You must use the data type that matches the value of the Goodheart-Willcox Publisher Figure 4-1. Certain rules must be followed when creating an identifier. Rules for Creating Java Identifiers Rules for Creating Java Identifiers • Must start with a “Java letter,” which is any lowercase (a–z) or uppercase (A–Z) letter, an underscore (_), or a dollar sign ($) letters in other languages represented by Unicode characters are also allowed. • After the first letter, can contain Java letters or digits (0–9). • Cannot contain any spaces. • Is case-sensitive. • Cannot be a Java keyword or reserved word. Goodheart-Willcox Publisher Figure 4-2. These are keywords and reserved words in Java. They cannot be used as identifiers. Java’s Keywords and Reserved Words Java’s Keywords and Reserved Words (underscore) _ continue for new switch abstract default goto package synchronized assert do if private this boolean double implements protected throw break else import public throws byte enum instanceof return transient case extends int short try catch final interface static void char finally long strictfp volatile class float native super while const Copyright Goodheart-Willcox Co., Inc. Chapter 4 Variables 75