void () { int N = 10; fillWithInts(N); gc(); Iterator<Object> iterator = myWeakList.iterator(); for (int i = 0; i < N; i++) { assertTrue(iterator.hasNext()); int element = (Integer)iterator.next(); assertEquals(i, element); iterator.remove(); } assertFalse(iterator.hasNext()); assertTrue(myWeakList.toStrongList().isEmpty()); }