如何创建仅接受实现Iterable的元素的方法

时间:2010-07-11 01:55:38

标签: java collections types generics iterable

我想编写一个函数printAll(),它只接受那些实现Iterable实现的元素,这样我就可以迭代它们并打印元素。我该怎么做?

1 个答案:

答案 0 :(得分:7)

public static void printAll(final Iterable<?> toIterate)

相关问题