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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CLASSES Method Declarations 8.4<br />

fields named RED happen to have the same type and the same unchanging value<br />

does not affect this judgment.<br />

8.3.3.4 Example: Re-inheritance of Fields<br />

If the same field declaration is inherited from an interface by multiple paths, the<br />

field is considered to be inherited only once. It may be referred to by its simple<br />

name without ambiguity. For example, in the code:<br />

public interface Colorable {<br />

int RED = 0xff0000, GREEN = 0x00ff00, BLUE = 0x0000ff;<br />

}<br />

public interface Paintable extends Colorable {<br />

int MATTE = 0, GLOSSY = 1;<br />

}<br />

class Point { int x, y; }<br />

class ColoredPoint extends Point implements Colorable {<br />

. . .<br />

}<br />

class PaintedPoint extends ColoredPoint implements Paintable<br />

{<br />

. . . RED . . .<br />

}<br />

the fields RED, GREEN, and BLUE are inherited by the class PaintedPoint both<br />

through its direct superclass ColoredPoint and through its direct superinterface<br />

Paintable. <strong>The</strong> simple names RED, GREEN, and BLUE may nevertheless be used<br />

without ambiguity within the class PaintedPoint to refer to the fields declared in<br />

interface Colorable.<br />

DRAFT<br />

8.4 Method Declarations<br />

<strong>The</strong> diversity of physical arguments and opinions embraces all sorts of methods.<br />

A method declares executable code that can be invoked, passing a fixed number of<br />

values as arguments.<br />

209

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

Saved successfully!

Ooh no, something went wrong!