Java Reference
In-Depth Information
declaration. For example, we could have written the two-argument Body
constructor as
public Body(String name, Body orbits) {
this();
this.name = name;
this.orbits = orbits;
}
The name and orbits fields are hidden from the constructor by the para-
meters of the same name. To access, for example, the name field instead
of the name parameter, we prefix it with this to specify that the name is
for the field belonging to "this" object. Deliberately hiding identifiers in
this manner is considered acceptable programming practice only in this
idiomatic use in constructors and "set" methodssome coding guidelines
and development environments advocate never hiding identifiers, even
in these cases. The way in which names are resolved is discussed in
" The Meanings of Names " on page 178 .
 
Search WWH ::




Custom Search