2

Javaの内部クラスと静的なネストされたクラスから、内部クラスとネストされたクラスについて知っています

しかし、Inner.redo1() と Inner.redo2() の違いは何ですか?

または、Inner.print1() と Inner.print2() は同じですか?

public class Outer {
    private String str = "outer";
    public void print() {
      System.out.println("a");
    }

    public class Inner {
        public void redo1() {
            print();
        }
        public void redo2() {
            Outer.this.print();
        }
    }
}

PS: java.util.ArrayList.Itr#remove で

public void remove() {
    if (lastRet < 0)
        throw new IllegalStateException();
    checkForComodification();

    try {
        ArrayList.this.remove(lastRet);
        cursor = lastRet;
        lastRet = -1;
        expectedModCount = modCount;
    } catch (IndexOutOfBoundsException ex) {
        throw new ConcurrentModificationException();
    }
}

を使用するのに使用しArrayList.this.remove(lastRet);ないのはなぜremove(lastRet);ですか?

4

2 に答える 2