Created
November 10, 2019 20:07
-
-
Save ms-Shifu/c373f1d79957c74cfe8bba40c07a156e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test3 { | |
public static void main(String[] args) { | |
Formula<Formula> formula = a -> a.sqrt(100); | |
System.out.println(formula.calculate(new ImplFormula(100))); | |
} | |
} | |
@FunctionalInterface | |
interface Formula<T> { | |
double calculate(T a); | |
default double sqrt(int a) { | |
return Math.sqrt(a); | |
} | |
} | |
class ImplFormula implements Formula { | |
private int val; | |
public ImplFormula(int val) { | |
this.val = val; | |
} | |
@Override | |
public double calculate(Object a) { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment