<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國際加速解決方案。 廣告
                ### [結合接口時的命名沖突](https://lingcoder.gitee.io/onjava8/#/book/10-Interfaces?id=%e7%bb%93%e5%90%88%e6%8e%a5%e5%8f%a3%e6%97%b6%e7%9a%84%e5%91%bd%e5%90%8d%e5%86%b2%e7%aa%81) 當實現多個接口時可能會存在一個小陷阱。在前面的例子中,**CanFight**和**ActionCharacter**具有完全相同的`fight()`方法。完全相同的方法沒有問題,但是如果它們的簽名或返回類型不同會怎么樣呢?這里有一個例子: ~~~ // interfaces/InterfaceCollision.java interface I1 { void f(); } interface I2 { int f(int i); } interface I3 { int f(); } class C { public int f() { return 1; } } class C2 implements I1, I2 { @Override public void f() {} @Override public int f(int i) { return 1; // 重載 } } class C3 extends C implements I2 { @Override public int f(int i) { return 1; // 重載 } } class C4 extends C implements I3 { // 完全相同,沒問題 @Override public int f() { return 1; } } // 方法的返回類型不同 //- class C5 extends C implements I1 {} //- interface I4 extends I1, I3 {} ~~~ 覆寫、實現和重載令人不快地攪和在一起帶來了困難。同時,重載方法僅根據返回類型是區分不了的。當不注釋最后兩行時,報錯信息如下: ~~~ error: C5 is not abstract and does not override abstract method f() in I1 class C5 extends C implements I1 {} error: types I3 and I1 are incompatible; both define f(), but with unrelated return types interfacce I4 extends I1, I3 {} ~~~ 當打算組合接口時,在不同的接口中使用相同的方法名通常會造成代碼可讀性的混亂,盡量避免這種情況。
                  <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>

                              哎呀哎呀视频在线观看