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.
|
|
available on the web at: |
http://mindprod.com/jgloss/iterator.html |
optional Replicator mirror
|
J:\mindprod\jgloss\iterator.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[54.234.67.55] |
|
| Feedback | You are visitor number 79,285. | |