google Ads

Friday, July 17, 2009

Variable names

Variable names


A program refers to a variable’s value by its name. For example, when the countChars methos wants to refer to the value of the count variable, it simply uses the name count. In Java, the following must hold true for a variable name.

1. It must be a legal java identifier comprised of a series of Unicode characters. Unicode is a character-coding system designed to support text written in diverse human languages. It allows for the codification of up to 65,356 characters, currently 34,168 have been assigned. This allows you to use characters in your Java programs from various alphabets, such as Japanese, Greek, Cyrillic, and Hebrew. This is important as it enables programmers can write code that is meaningful in their native languages.

2. It must not be a keyword or a boolean literal ( true or false).

3. It must not have the same name as another variable whose declaration appears in the same scope.


Rules:

1. A variable cannot starts with a numeral (Example: 1d, 88hak, 66emp, 888sal, etc).

2. It has start with a alphabet or _ (Underscore) or $ (Dollar).
Example : _myEmployee, $salary

3. A variable names should be starts with a lowercase and class name starts with a UPPERCASE.

4. If a variable name consists of more than one word, such as isVisible, the words are joined together and each word after the first begins with an uppercase letter.

No comments:

Post a Comment