10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.1 Declarations NAMES<br />

114<br />

(§15.11), or a method invocation expression (§15.12) in which the method is not<br />

specified by a simple name. <strong>The</strong> default access is that a member can be accessed<br />

anywhere within the package that contains its declaration; other possibilities are<br />

public, protected, and private.<br />

Fully qualified and canonical names (§6.7) and naming conventions (§6.8) are<br />

also discussed in this chapter.<br />

<strong>The</strong> name of a field, parameter, or local variable may be used as an expression<br />

(§15.14.2). <strong>The</strong> name of a method may appear in an expression only as part of a<br />

method invocation expression (§15.12). <strong>The</strong> name of a class or interface type may<br />

appear in an expression only as part of a class literal (§15.8.2), a qualified this<br />

expression (§15.8.4), a class instance creation expression (§15.9), an array creation<br />

expression (§15.10), a cast expression (§15.16), an instanceof expression<br />

(§15.20.2), an enum constant (§8.9), or as part of a qualified name for a field or<br />

method. <strong>The</strong> name of a package may appear in an expression only as part of a<br />

qualified name for a class or interface type.<br />

6.1 Declarations<br />

A declaration introduces an entity into a program and includes an identifier (§3.8)<br />

that can be used in a name to refer to this entity. A declared entity is one of the following:<br />

• A package, declared in a package declaration (§7.4)<br />

• An imported type, declared in a single-type-import declaration (§7.5.1) or a<br />

type-import-on-demand declaration (§7.5.2)<br />

• A class, declared in a class type declaration (§8.1)<br />

• An interface, declared in an interface type declaration (§9.1)<br />

• A type variable (§4.4), declared as a formal type parameter of a generic class<br />

(§8.1.2), interface (§9.1.2), method (§8.4.4) or constructor (§8.8.1).<br />

• A member of a reference type (§8.2, §9.2, §10.7), one of the following:<br />

DRAFT<br />

◆ A member class (§8.5, §9.5).<br />

◆ A member interface (§8.5, §9.5).<br />

◆ an enum constant (§8.9).<br />

◆ A field, one of the following:<br />

❖ A field declared in a class type (§8.3)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!