1

Is there anything in Android like IEnummerable in C#?

I have a method that needs to be able to take an List of a type, as well as an array of the same type, and enumerate thru the elements of either and do the same thing to them.

In C# I would write one method, taking an IEnumerable and use it for both purposes. I could overload the method to accept both types, but I'd rather just have one method, since both would do the same thing anyway.

Does such a thing exist? And if not, is there another way to do this with only one method?

  • each `Iterable` (Lists are) has `.iterator()` which has `.hasNext()` etc. You can also do `for(Type t : IterableOfType) { // access t }` to iterate over those – zapl Mar 16 '12 at 16:52

1 Answers1

0

I'm afraid there is no equivalent to IEnumerable in Java. You might want to have a look at this, though.

Community
  • 1
  • 1
hgllnt
  • 338
  • 2
  • 10