在这样的类之后,如何使用"this"?

Cha*_*all 3 java this

我不太明白this在这个例子中如何使用关键字.

private void checkForComodification() {
    // The this I'm concerned about is the first one
    if (CyclicArrayList.this.modCount != this.modCount)
        throw new ConcurrentModificationException();
}
Run Code Online (Sandbox Code Playgroud)

Thi*_*ilo 5

你有时需要内部课程.

this 指向内部类实例本身.

MyOuterClass.this 指向包含类的实例.

在您的情况下,这是必要的,因为两个类都有一个modCount属性(外部类中的一个CyclicArrayList被遮蔽).