我从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);
?