NAMES
The Members of an Interface Type
6.4.3
A class type may have two or more methods with the same simple name if the
methods have different signatures ( 8.4.2), that is, if they have different numbers
of parameters or different parameter types in at least one parameter position. Such
a method member name is said to be
overloaded
.
A class type may contain a declaration for a method with the same name and
the same signature as a method that would otherwise be inherited from a super 
class or superinterface. In this case, the method of the superclass or superinterface
is not inherited. If the method not inherited is
abstract
, then the new declaration
is said to
implement
 it; if the method not inherited is not
abstract
, then the new
declaration is said to
override
 it.
In the example:
class Point {
float x, y;
void move(int dx, int dy) { x += dx; y += dy; }
void move(float dx, float dy) { x += dx; y += dy; }
public String toString() { return "("+x+","+y+")"; }
}
the class
Point
 has two members that are methods with the same name,
move
.
The overloaded
move
 method of class
Point
 chosen for any particular method
invocation is determined at compile time by the overloading resolution procedure
given in  15.11.
In this example, the members of the class
Point
 are the
float
 instance vari 
ables
x
 and
y
 declared in
Point
, the two declared
move
 methods, the declared
toString
 method, and the members that
Point
 inherits from its implicit direct
superclass
Object
 ( 4.3.2), such as the method
hashCode
 ( 20.1.4). Note that
Point
 does not inherit the
toString
 method ( 20.1.2) of class
Object
 because
that method is overridden by the declaration of the
toString
 method in class
Point
.
6.4.3   The Members of an Interface Type
The members of an interface type ( 9.2) are fields and methods. The members of
an interface are all of the following:
Members inherited from any direct superinterfaces ( 9.1.3)
Members declared in the body of the interface ( 9.1.4)
An interface may have two or more fields with the same simple name if they
are declared in different interfaces and inherited. An attempt to refer to any such
field by its simple name results in a compile time error ( 6.5.5.1,  9.2).
87






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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