我有以下全局数组...
public static float camObjCoord[] = new float[8000];
我有一种方法可以将值输入到它的索引中,我会像这样发送它们...
layers.addcube(-6, -2, -6, -2);
i 是一个声明为..的类变量
int i = 0;
层被声明为...
GLLayer layers = new GLLayer(this);
但是当我这样做时,我在...处得到一个 NullPointerException
public void addcube(float highx, float lowx, float highz, float lowz){
//Constructing new cube...
cubes++;
float highy = 4.5f;
float lowy = 2.5f;
//FRONT
Global.camObjCoord[i] = highx; //null pointer here.
有谁知道为什么它给我一个空指针?还有更多的代码,但我认为只给你相关的代码就足够了。
谢谢
最佳答案
尝试将其更改为:
public final static float camObjCoord[] = new float[8000];
正如我假设您在这里更新 camObjCoord 并将其设置为空。否则我看不出您如何在该行中获得 NullPointerException。
关于java - 奇怪的空指针异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3228891/