我已阅读http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-4.html并注意到所有示例都明确声明了参数类型,即使它已经从接口函数声明中知道.
public interface FileFilter {
/** ... **/
boolean accept(File pathname);
}
FileFilter java = (File f) -> f.getName().endsWith(".java");
我们不能一起去吗
(f) -> f.getName().endsWith(".java"); ?
更新:在JSR-335 Draft 中,我发现最有可能支持推断类型参数
(int x) -> x+1 // Single declared-type parameter
(int x) -> { return x+1; } // Single declared-type parameter
(x) -> x+1 // Single inferred-type parameter
x -> x+1 // Parens optional for single inferred-type case