Java: Passing a Function as a Parameter like in JavaScript?
<p>I'm trying to write a function, so I can pass a function as a parameter, such as</p>

<pre><code>public class HashFunction {
    private Function f;
    public HashFunction(Function f) {
        this.f=f;
    }
    public Integer hash(String s){
        return f(s);
    }
}
</code></pre>

<p>So I can write code like</p>

<pre><code>new HashFunction(function(String s){ return s.charAt(0)+0; });
</code></pre>

<p>Like in javascript.
How can I do this?</p>
