Jaime in Java
Jaime Caetano wrote:I'm having trouble undestanding the point of Iterable interface.
whats the purpose of Iterable?
well since it haves a method that returns an iterator, if I implement Iterable it will make me create an Iterator right?
what is really the iterator real use?
Jaime in Java
Jaime Caetano wrote:can you tell me a little more of how the Iterable relates to the for each loop?
Jaime in Java
Jaime Caetano wrote:yes I did use it before, so in order to for each loop go on, it first checks if the variable is from an iterable collection, is that right?
Jaime in Java
Jaime Caetano wrote:I'm trying all this and so I made a class Test and now:
I can't really understand what is the Iterator() for... cause I made it return null, and the main output its the same as having returning an iterator...
Joanne
Jaime in Java
Jaime Caetano wrote:
I understood, t2 is iterable and it is a object,
but is there any point in your example?
what happens if you loop through a single object?
ermmmm....
Jaime in Java
Jaime in Java
Jaime Caetano wrote:thank you a lot for the good example Rico,
so imagine you had a Collection there instead of an array,
to make your shoppingList Iterable, you could simply
make an Iterator<String> it = list.iterator();
well java could solve this by turning all data structures Iterable already right??
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here