Skip to content

Instantly share code, notes, and snippets.

@ms-Shifu
Created November 10, 2019 20:07
Show Gist options
  • Save ms-Shifu/c373f1d79957c74cfe8bba40c07a156e to your computer and use it in GitHub Desktop.
Save ms-Shifu/c373f1d79957c74cfe8bba40c07a156e to your computer and use it in GitHub Desktop.
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