私はこれまでにうまく動作する古いプロジェクトを持っていますが、今日開いてコンパイラが'cannot find symbol Integer.valueOf(int)'
または'cannot find symbol Integer.toHexString(int)'
と言ってくれました。シンボルを見つけることができませんInteger.valueOf(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();
}
}
}
古いJavaバージョンも使用していますか? – voldy
http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#valueOf-int-によると、1.5では、Integer.valueOf(int i)がJavaに追加されました。使用しているJava IntelliJのバージョンを確認してください。 – ajb
私のプロジェクトをコンパイルするためにintellijがjdk1.8を使用していると確信しています。「情報:javac 1.8.0_101がJavaソースをコンパイルするために使用されました」というログが表示されます。私のマシンにはjdk7とjdk8があり、両方ともjdk5の上にあります。 – luxuanren