Java Reference
In-Depth Information
ȗ
Identifiers are also case sensitive; that is, greeting and Greeting are
different.
By convention, variable names should start with a lowercase letter.
These are firm rules of the Java language. If you violate one of them, the compiler will
report an error. Moreover, there are a couple of conventions that you should follow so
that other programmers will find your programs easy to read:
35
36
ȗ
Variable and method names should start with a lowercase letter. It is OK to use
an occasional uppercase letter, such as lucky N umber . This mixture of
lowercase and uppercase letters is sometimes called Ȓcamel caseȓ because the
uppercase letters stick out like the humps of a camel.
ȗ
Class names should start with an uppercase letter. For example, Greeting
would be an appropriate name for a class, but not for a variable.
If you violate these conventions, the compiler won't complain, but you will confuse
other programmers who read your code.
S ELF C HECK
1. What is the type of the values 0 and Ȓ0ȓ?
2. Which of the following are legal identifiers?
Greeting1
g
void
101dalmatians
Hello, World
<greeting>
3. Define a variable to hold your name. Use camel case in the variable name.
2.2 The Assignment Operator
You can change the value of an existing variable with the assignment operator (=). For
example, consider the variable definition
Search WWH ::




Custom Search