gpt4 book ai didi

java - 为什么我不能在列表上使用 Apache 的 StringUtils.join?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:09:06 24 4
gpt4 key购买 nike

当我尝试

StringUtils.join(myList,',');

编译失败:

cannot find symbol
symbol : method join(java.util.List,char)

但以下工作:

StringUtils.join(myList.toArray(),',');

docs (Apache Commons Lang 2.5)似乎表明两者都应该起作用,因为它们记录了两者:

public static String join(Collection collection,
char separator)

public static String join(Object[] array,
char separator)

有什么想法吗?作为记录,我正在导入 import org.apache.commons.lang.StringUtils;

最佳答案

最可能的原因是,您使用的是旧版本的 Commons Lang,因为使用 Collection 的方法仅在 2.3 中添加。

您可以通过在 Implementation-Version 字段中查看 Jar 中的 MANIFEST.MF 文件来检查这一点。

关于java - 为什么我不能在列表上使用 Apache 的 StringUtils.join?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7164910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com