Eclipse类型推断问题

时间:2017-12-19 19:16:36

标签: eclipse

在Eclipse Oxygen上运行,创建局部变量(Cmd-1)会导致Object而不是推断类型。

public static void main(String[] args) {
    Object x = get("test", o -> o.length());
}

public static <A, B> B get(A target, Function<A, B> func1) {
    B result = func1.apply(target);

    return result;
}

我希望将x创建为int

有什么想法吗?

感谢。

0 个答案:

没有答案