Vector<Vector<Integer>> wavesInformation;
for(Vector<Integer> waveInformation : wavesInformation) {
for(Integer enemyIndex : waveInformation) {
}
}
Run Code Online (Sandbox Code Playgroud)
给出运行时错误:
Exception in thread "LWJGL Application" java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Integer
Run Code Online (Sandbox Code Playgroud)
在for(Integer enemyIndex : waveInformation) {行.
这很混乱,因为没有使用浮动.
写作
for(Float enemyIndex : waveInformation) {
Run Code Online (Sandbox Code Playgroud)
给出编译错误:
Type mismatch: cannot convert from element type Integer to Float
Run Code Online (Sandbox Code Playgroud)
编辑:
我wavesInformation在调试模式下查找,发现存储的数字实际上是浮点数(0.0).
EDIT2:
嗯,这真的很奇怪.
出于实验目的,我将for循环更改为:
for(int i = 0 ; i < waveInformation.size() ; i++) {
Run Code Online (Sandbox Code Playgroud)
我试图将值waveInformation赋给变量,如下所示:
float x = waveInformation.get(i);
Run Code Online (Sandbox Code Playgroud)
和: …