fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class TestClass {
  6.  
  7. @FunctionalInterface
  8. public interface ToDoubleFunction<T extends TestClass, U extends Number> {
  9. Double applyAsDouble(T classInstance, U value);
  10. }
  11.  
  12. <U extends Number> Double getDouble(U value) {
  13. System.out.println(this);
  14.  
  15. return value.doubleValue();
  16. }
  17.  
  18. public static void main (String[] args) throws java.lang.Exception
  19. {
  20. ToDoubleFunction<TestClass, Long> tdf = TestClass::getDouble;
  21.  
  22. TestClass c = new TestClass();
  23.  
  24. System.out.println(c);
  25.  
  26. System.out.println(tdf.applyAsDouble(c, new Long(43)));
  27. }
  28. }
Success #stdin #stdout 0.19s 320704KB
stdin
Standard input is empty
stdout
TestClass@3abc88
TestClass@3abc88
43.0