How would you port this c# code over to Java?
public Hash(object defaultValue)
: this()
{
_defaultValue = defaultValue;
}
public Hash(Func<Hash, string, object> lambda)
: this()
{
_lambda = lambda;
}
public Hash()
{
_nestedDictionary = new Dictionary<string, object>(Template.NamingConvention.StringComparer);
}
The closest thing that Java has to delegates is a single method interface using an anonymous inner class. The Callable interface is somewhat similar to Func.
See these questions:
Equivalent of C# anonymous methods in Java?
Java's equivalents of Func and Action