2015-09-07 11:44:36 -06:00
|
|
|
|
// innerclasses/CtorReference.java
|
2015-06-15 17:47:35 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
|
|
|
|
// Demonstrates java.util.function
|
|
|
|
|
import java.util.function.*;
|
|
|
|
|
import static com.mindviewinc.util.Print.*;
|
|
|
|
|
|
|
|
|
|
public class CtorReference {
|
|
|
|
|
public CtorReference() {
|
|
|
|
|
print("Inside CtorReference()");
|
|
|
|
|
}
|
|
|
|
|
public CtorReference(int i) {
|
|
|
|
|
print("Inside CtorReference(i)");
|
|
|
|
|
}
|
|
|
|
|
public CtorReference(int i, double d) {
|
|
|
|
|
print("Inside CtorReference(i, d)");
|
|
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Supplier<CtorReference> cr0 =
|
|
|
|
|
CtorReference::new;
|
|
|
|
|
CtorReference r0 = cr0.get();
|
|
|
|
|
|
|
|
|
|
Function<Integer, CtorReference> cr1 =
|
|
|
|
|
CtorReference::new;
|
|
|
|
|
CtorReference r1 = cr1.apply(1);
|
|
|
|
|
|
|
|
|
|
BiFunction<Integer, Double, CtorReference> cr2 =
|
|
|
|
|
CtorReference::new;
|
|
|
|
|
CtorReference r2 = cr2.apply(1, 2.0);
|
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Inside CtorReference()
|
|
|
|
|
Inside CtorReference(i)
|
|
|
|
|
Inside CtorReference(i, d)
|
2015-09-07 11:44:36 -06:00
|
|
|
|
*/
|