Friday, 27 July 2007

Java Language Fundamentals (Part 2)

Java Language Fundamentals (Part 2)


Identifiers


Identifiers are the blocks of a programming language - that is, they are the entities (values and data) that act or are acted upon. An identifier can be any length, but it must start with a letter, an underscore or a dollar sign. The rest of the identifier can include any characters except for those that are used as operators, e.g. +, -, * and others. There is one more restriction, you can’t use keywords in Java as a variable name. Valid identifiers are:



  • Identifier

  • UserName

  • User_Name

  • _Sys_name

  • $changeName


Java uses 16 bit Unicode rather than 8 bit ASCII text, so a letter has a considerably wider definition than just a to z or A to Z.


As mentioned before, an identifier can’t be a keyword, but it can contain a keyword as part of it’s name. For example:

importText()
is valid even though import is a keyword.

No comments: