以下代码应该有效,因为世代odicetagcode接受迭代器作为参数:

import static org.apache.commons.lang.StringUtils.join;
import java.text.StringCharacterIterator;

…

join(new StringCharacterIterator("A String"), " ");
.

ala,它没有。有人可以向我解释为什么?

有帮助吗?

解决方案

According to the documentation, StringCharacterIterator inherits from and only from CharacterIterator. A CharacterIterator does not inherit from a generic Iterator, which is what join wants.

http://download.oracle.com/javase/1.4.2/docs/api/java/text/CharacterIterator.html

其他提示

First of all, the join method takes two arguments : an iterator and a separator string or char.

And if you look at the javadoc of StringCharacterIterator, you'll see that this class does not implement java.util.Iterator.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top