我重新打开一个编译并运行良好的项目,但出现错误:
"String cannot be converted to CharSequence"
所有涉及字符串操作的行,例如:
String status = "blah blah";
int countArobase = StringUtils.countMatches(status, "@");
// error "String cannot be converted to CharSequence" at the "@" String.
注意:StringUtils
来自org.apache.commons.lang3.StringUtils
与 native 方法相同的错误,例如:
String feature;
boolean test = feature.contains("blah blah");
// error "String cannot be converted to CharSequence" at the "blah blah" String.
太奇怪了,我几乎怀疑IDE有问题? (我使用NetBeans 8.0.2)
最佳答案
您是否检查过用于在 NetBeans 中构建项目的 JDK 和 JRE 版本?
如果您在编译时遇到问题,请检查您的 JDK,否则请检查您的 JRE。
如果您正在使用某些构建工具,请检查用于构建工具的 JDK 以及 Java 编译器的 -source
和 -target
。
关于java - Java项目中到处都是"String cannot be converted to CharSequence"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34071370/