Fifty key words are currently defined in the Java language .These keywords, combined with the syntax of the operators and separators, form the definition of the Java language. These keywords cannot be used as names for a variable, class, or method. The key words const and go to are reserved but not used. In the early days of Java, several other keywords were reserved for possible future use. However, the current specification for Java defines only the keywords shown in Table. The enum key word is quite new.It was added by J2SE5. In addition to the key words ,Java reserves the following: true, false, and null. These are values defined by Java. You may not use these words for the names of variables, classes, and so on.
In Java an identifier is a name given to a method, a variable, or any other user-defined item. Identifiers can be from one to several characters long. Variable names may start with any letter of the alphabet, an underscore, or a dollar sign. Next may be either a letter, a digit, a dollar sign, or an underscore. The underscore can be used to enhance the readability of a variable
name, as inline_count. Uppercase and lowercase are different; that is, to Java,myvar and MyVarare separate names. Here are some examples of acceptable identifiers:
Test x y2 MaxLoad
$up _top my_var sample23
Remember,
you can’t start an identifier with a digit. Thus, 12xis invalid, for example. You cannot use any of the Java keywords as identifier names. Also, you should not assign the name of any standard method, such as println, to an identifier. Beyond these two restrictions, good programming practice dictates that you use identifier names that reflect the meaning or usage of the items being named.
0 comments:
Post a Comment