gpt4 book ai didi

java - 找不到符号 Integer.valueOf(int)

转载 作者:太空宇宙 更新时间:2023-11-04 11:18:02 27 4
gpt4 key购买 nike

我有一个以前运行良好的旧项目,但今天打开它,发现编译器告诉我'找不到符号Integer.valueOf(int)''找不到符号Integer.toHexString(int)'

java.lang.Integer 好像有问题。我使用 IntelliJ,它编译失败,如上,但 Eclipse 工作正常。此外,我使用将相同的代码粘贴到新的 IntelliJ 项目中,它也工作得很好。

我的旧 IntelliJ 项目的配置有什么问题吗?有人以前遇到过这个问题吗?

示例代码如下:

public class ContainerTest {
public static void main(String[] args) {
@SuppressWarnings("unchecked")
List numbers = new ArrayList(Arrays.asList(1, 2, 3)); // cannot find Integer.valueOf(int) here
ListIterator listIterator = numbers.listIterator();

while (listIterator.hasNext()) {
System.out.println("index" + listIterator.nextIndex() + " : " +listIterator.next());
listIterator.add(100);
}

System.out.println(numbers);
}
}

public class BinaryFileTest {
public static void main(String[] args) throws IOException {
DataInputStream reader = null;

try {
String filename = "./target/classes/io/TreeInfo.class";
reader = new DataInputStream(new FileInputStream(new File(filename)));
int i = 0, k;

while (reader.available() != 0 && i++ < 4) {
System.out.println(Integer.toHexString(k = reader.read())); // here
System.out.println(k);
}

reader.close();

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
reader.close();
}
}
}

最佳答案

当您使用不支持该方法的版本时,这是很常见的,要解决此问题,请确保您在两个 IDE(Eclipse 和 IntelliJ)中使用相同的版本。在 IntelliJ 中,您可以在 Project Settings > Project 中进行设置,选择正确的 Project SDK 版本,同样在 Project Settings > Modules 中选择您的项目,单击 Dependencies 选项卡并选择正确的 Module SDK 版本。

关于java - 找不到符号 Integer.valueOf(int),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45250337/

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