为什么Stringutils.join接受一个Stringcharrayerator?
-
14-11-2019 - |
题
以下代码应该有效,因为世代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
.
不隶属于 StackOverflow