0 votes
in JAVA by
Can I write my own container class and use it in the for-each loop?

1 Answer

0 votes
by

Yes, you can write your own container class. You need to implement the Iterable interface if you want to loop over advanced for loop in Java, though. If you implement Collection then you by default get that property.

...