[英]How to Create a Method that only accepts elements that implement Iterable
I want to write a function printAll(), which accepts only those elements that implement that implement Iterable so that I can iterate over them and print the elements. 我想编写一个函数printAll(),该函数仅接受那些实现了Iterable的元素,以便我可以对其进行迭代并打印这些元素。 How do I do that?
我怎么做?
public static void printAll(final Iterable<?> toIterate)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.