该错误的原因是变量里面使用了com.sun.org.apache.xpath.internal.operations.String这个包下的String类型,而它和java.lang.String类型不兼容。解决方法是将引用的包修改为正确的包,或者直接使用java.lang.String类型。以下是示例代码:
错误示例:
import com.sun.org.apache.xpath.internal.operations.String;
public class Test { public static void main(String[] args) { String str = "Hello world!"; System.out.println(str); } }
正确示例:
import java.lang.String;
public class Test { public static void main(String[] args) { String str = "Hello world!"; System.out.println(str); } }