NAMES
Constant Names
6.8.5
Whenever possible and appropriate, basing the names of methods in a new class
on names in an existing class that is similar, especially a class from the standard
Java Application Programming Interface classes, will make it easier to use.
Method names cannot hide or be hidden by other names ( 6.5.6).
6.8.4 Field Names
Names of fields that are not
final
should be in mixed case with a lowercase first
letter and the first letters of subsequent words capitalized. Note that well designed
Java classes have very few
public
or
protected
fields, except for fields that are
constants (
final static
fields) ( 6.8.5).
Fields should have names that are nouns, noun phrases, or abbreviations for
nouns. Examples of this convention are the fields
buf
,
pos
, and
count
of the class
java.io.ByteArrayInputStream
( 22.6) and the field
bytesTransferred
of
the class
java.io.InterruptedIOException
( 22.30.1).
Hiding involving field names is rare.
If a field name hides a package name, then an
import
declaration ( 7.5) can
usually be used to make available the type names declared in that package.
If a field name hides a type name, then a fully qualified name for the type can
be used.
Field names cannot hide method names.
If a field name is hidden by a declaration of a parameter or local variable, then
the name of the parameter or local variable can be changed without affecting
other Java code.
6.8.5 Constant Names
The names of constants in interface types should be, and
final
variables of class
types may conventionally be, a sequence of one or more words, acronyms, or
abbreviations, all uppercase, with components separated by underscore
_
char
acters. Constant names should be descriptive and not unnecessarily abbreviated.
Conventionally they may be any appropriate part of speech. Examples of names
for constants include
MIN_VALUE
,
MAX_VALUE
,
MIN_RADIX
, and
MAX_RADIX
of the
class
java.lang.Character
.
A group of constants that represent alternative values of a set, or, less fre
quently, masking bits in an integer value, are sometimes usefully specified with a
common acronym as a name prefix, as in:
109
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved