I get aNullPointerException
when I try to run this code:
private static Semaphore[] trackSemas;
for(int i=0;i<9;i++){
trackSemas[i] = new Semaphore(1,true);
}
Why doesn't this bit of code get a NullPointerException?
I get aNullPointerException
when I try to run this code:
private static Semaphore[] trackSemas;
for(int i=0;i<9;i++){
trackSemas[i] = new Semaphore(1,true);
}
Why doesn't this bit of code get a NullPointerException?
You need to initialize the trackSemas
array:
private static Semaphore[] trackSemas = new Semaphore[9];