<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 2.4.3 Function復合 函數(Function)接口包括addThen、compose以及apply這幾個常用方法。 下面的例子展示了函數復合的用法,以及addThen和compose的區別。 - **addThen**:對于 `f.addThen(g)` ,先計算f,再計算g - **compose**:對于 `f.addThen(g)` ,先計算g,再計算f - **apply**:執行 ``` import java.util.function.Function; import java.util.function.IntFunction; public class ComplexFunctionTest { public static void main(String[] args) { Function<String, String> insertHeader = str -> "頭部文本 " + str; Function<String, String> insertFooter= str -> str + " 尾部文本"; Function<String, String> replace = str -> str.replaceAll("A", "B"); Function strFun = insertHeader.andThen(insertFooter).andThen(replace); System.out.println(strFun.apply("A B C D")); // "頭部文本 B B C D 尾部文本" /* addThen和compose的區別 */ Function<Integer,Integer> f = x -> x + 1; Function<Integer,Integer> g = x -> x * 2; Function f1 = f.andThen(g); // 先執行f,再執行g Function f2 = f.compose(g); // 先執行g,再執行f System.out.println(f1.apply(1)); // 4 = (1 + 1) * 2 System.out.println(f1.apply(2)); // 6 = (2 + 1) * 2 System.out.println(f1.apply(3)); // 8 = (3 + 1) * 2 System.out.println(f2.apply(1)); // 3 = (1 * 2) + 1 System.out.println(f2.apply(2)); // 5 = (2 * 2) + 1 System.out.println(f2.apply(3)); // 7 = (3 * 2) + 1 } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看