When should I accept a parameter of Iterable vs. Collection in Java?

后端 未结 9 1613
独厮守ぢ
独厮守ぢ 2021-01-30 01:06

What are the considerations of using Iterable vs. Collection in Java?

For example, consider implementing a type that is primarily concerned with contai

9条回答
  •  情深已故
    2021-01-30 01:18

    According to the principle of least surprise, you should emulate the Java collection pattern and take a Collection constructor arg. It will make the people who come after you slightly less puzzled.

提交回复
热议问题