Java Reference
In-Depth Information
In the program, pay special attention to this line:
It creates a method reference to the instance method isFactor( ) that will work with any
object of type MyIntNum . For example, when test( ) is called through the inp , as shown
here:
it results in a call to myNum.isFactor(3) . In other words, myNum becomes the object on
which isFactor(3) is called.
Constructor References
Similar to the way that you can create references to methods, you can also create references
to constructors. Here is the general form of the syntax that you will use:
classname ::new
This reference can be assigned to any functional interface reference that defines a method
compatible with the constructor. Here is a simple example:
Search WWH ::




Custom Search