Can you create a single Iterator that will step over all spaces in a 2d array?
If you implement the Iterable interface, you can use a for-each loop. Related examples may be found here.
Yes, wrap the array in an object and make the object implement the iterator interface. So it can be done. I am not aware of any such iterator that ships with the Jdk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With