Java Reference
In-Depth Information
By convention, most identifiers are mixed case, and instance identifiers (vari-
ables, objects, members, and so on) begin with an initial lowercase. User-de-
fined types, such as classes, often begin with an initial uppercase. Static class
variables and members are normally all uppercase.
Valid names cannot start with a numeric character.
Here are some examples of valid identifier names, and what they represent, by
convention (based on Sun's coding conventions found at http://java.sun.com/docs/
codeconv/html/CodeConvTOC.doc.html):
msgSize
// an instance identifier
m_ErrorMsg
// an instance identifier, probably an object identifier
ErrorMsg
// a user-defined type, such as a class name
NO_TEXT_FOUND
// a static CLASS variable
Here are some invalid identifier names:
1instanceVariable
// cannot start with nonalpha
another instance variable
// embedded spaces
COBOL-STYLE
// embedded dashes
public
// reserved word
A Java executable statement performs some part of a class's algorithm (it is sim-
ilar to a sentence in COBOL's procedure division). These statements can contain
multiple expressions, all of which will be performed as part of the statement.
This is a simple Java expression that declares a String type object:
String inputMsg
Placing a semicolon at the end makes it a complete Java statement:
String inputMsg;
This is a Java expression that performs the method getErrorMsg() in the object
myErrorMsg and passes no parameters:
myErrorMsg.getErrorMsg ()
This expression can be combined with an assignment expression in order to re-
turn the result into inputMsg :
Search WWH ::




Custom Search