문제

join는 반복자를 인수로 받아들이므로 다음 코드가 작동해야합니다.

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

…

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

alas, 그렇지 않습니다.누군가 나에게 왜 설명 할 수 있니?

도움이 되었습니까?

해결책

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