2012-04-08 46 views
3

我正在扩展ArrayList以创建一个自定义ArrayList,它可以在迭代时使用正常的ArrayList方法进行修改。为此,我也创建了一个迭代器。在我的hasNext()和next()方法中,我需要确保列表没有被修改(它可以在任何其他时间被修改)。在我的hasNext()和next()方法中,我需要确保列表不会被修改。因此,我需要在我的synchronized()块中引用我的封闭类型。如何引用从内部类包围类?

+0

[Access Outer Class this instance](http://stackoverflow.com/questions/1721608/access-outer-class-this-instance)和[获取内部类对象的外部类对象](http://stackoverflow.com/questions/1816458/getting-hold-of-the-outer-class-object-from-the-inner-class-object) – 2012-04-08 02:57:06

回答

5

EnclosingType.this。所以在你的情况下,它将是SynchronizedList.this

相关问题