Iterable is the interface that notes the class has a iterator method capable of emitting a one-shot Iterator object. Since Iterable in a superinterface of Collection, all Collections are Iterable, but not the reverse. The for:each shorthand loop syntax works only on classes than implement Iterable.
| Sample Code | Iterable |
| Generics | Learning More |
| Implementing | Links |
| Remove |
Deleting a large number of elements from a large ArrayList will run faster if you create a new ArrayList just the right size, then populate it leaving out the undesirable elements. This avoids the repeated sliding down of all elements above the deleted one. Also processing an ArrayList in descending order to delete is more efficient since remove will not need to slide elements that will be soon deleted.
Here is some sampe code to use Iterator.remove.
| You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | |
| http://mindprod.com/jgloss/iterator.html | J:\mindprod\jgloss\iterator.html | |
![]() | ||
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.191.109] | |
| Feedback | You are visitor number 56,721. | |