【问题标题】:Why Java Function default method "andthen" type parameter is just <V>?为什么Java函数默认方法“andthen”类型参数只是<V>?
【发布时间】:2022-01-14 05:00:10
【问题描述】:

Java documentation,我看到了:

default <V> Function<T,V> andThen(Function<? super R,? extends V> after)

为什么是&lt;V&gt;,而不是&lt;V, R&gt;

【问题讨论】:

  • 没有?有andThen(Function&lt;? super R, ? extends V&gt;,哪里没有&lt;V&gt;
  • 你能格式化问题中的代码吗?其中一些被解释为 HTML 标记,因此呈现的输出缺少信息。
  • 欢迎来到 Stack Overflow。我尝试编辑问题以避免格式问题并清楚地提出问题。

标签: java generics


【解决方案1】:

R 是在Function 接口级别定义的,而不是在andThen 方法调用级别。您不需要包含属于具有该方法的类型的类型参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 2022-10-21
    • 1970-01-01
    • 2013-04-06
    相关资源
    最近更新 更多