Java Arrays & Generics : Java Equivalent to C# IEnumerable

前端 未结 5 1056
小鲜肉
小鲜肉 2020-12-15 15:12

So in C#, I can treat a string[] as an IEnumerable.

Is there a Java equivalent?

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 15:32

    Iterable is OK, but there is a small problem. It cannot be used easily in stream() i.e lambda expressions.

    If you want so, you should get it's spliterator, and use the class StreamSupport().

提交回复
热议问题