All Java components require names. Name used for classes, methods, interfaces and variables are called Identifier. Identifier must follow some rules. Here are the rules:
- All identifiers must start with either a letter( a to z or A to Z ) or currency character($) or an underscore(_).
- After the first character, an identifier can have any combination of characters.
- A Java keyword cannot be used as an identifier.
- Identifiers in Java are case sensitive, off and Off are two different identifiers.
- Legal
- Illegal
- MyVariable
- myvariable
- MYVARIABLE
- x
- i
- My Space //Contains a space
- 9pins6s // Begins with a digit
- k+h // The plus sign is not an alphanumeric character testing
- 61-72-83 // The hyphen is not an alphanumeric character
No comments:
Post a Comment