Instance
Direct triangles, which are counted on the third side by both sides, are intended to be used to refer to these methods. The code is a bit more inappropriate, forgive yourself.
static method Reference
The parameter list of the interface is the same as the parameter list of the specific implementation method in the class, and the return value is consistent.
Call
Static references
Istaticside staticside = five::getstaticsize;
Staticside.getstaticsize (3, 6);
Class is defined in the
Static references
public static double getstaticsize (double s,double s2)
{
Return math.sqrt (S*S+S2*S2);
}
Defining interfaces
Interface istaticside{
Double getstaticsize (double s,double S2);
}
Instance reference
The parameter list of the interface is the same as the parameter list of the specific implementation method in the class, and the return value is consistent.
Call
Five Five = new Five (3,4);
Instance Reference method
Ilastside Side=five::getthelastside;
SYSTEM.OUT.PRINTLN ("instance reference, result of method third side:" +side.getlastside ());
Class is defined in the
Type reference
Public double getfivelastside (Five f) {
Return math.sqrt (THIS.SIDE1 * this.side1 + this.side1 * this.side1);
}
Defining interfaces
Interface Ilastside {
Double Getlastside ();
}
A method defined in a type reference class has only one parameter, that is, the class of the comparison, that is, the interface defining the second parameter in the interface must be two parameters, the first parameter refers to the class, the second argument refers to the class call of the comparison
Type reference
Ilastfiveside typeside = five::getfivelastside;
SYSTEM.OUT.PRINTLN ("type reference, result of the third side:" +typeside.getlastside (five, five));
Class is defined in the
Type reference
Public double getfivelastside (Five f) {
Return math.sqrt (THIS.SIDE1 * this.side1 + this.side1 * this.side1);
}
Interface definition
Interface Ilastfiveside {
Double Getlastside (Five F, Five F2);
}
Construct references
The reference constructor, by example, is a reference to return an object, and then the object is then called by the corresponding method to execute.
Call
Constructor reference
Igetinstance instace = five::new;
System.out.println ("constructor reference, result of the third side:" +instace.getinstance). Getthelastside ());
Class is defined in the
Constructor reference
Public Five getinstance (double s, double s2) {
return new Five (s, S2);
}
Interface definition
The result interface after receiving the reference
Interface Igetinstance {
Five getinstance (double s, double S2);
}
Something
Just yourself through a simple example summary, if there is no place to hope the Great God gate Jiangshan. I have previously been engaged in. NET development, Java knowledge is indeed insufficient, hope that a lot of understanding, do not want to pit teammates.
Java Basics-Four method references