I am trying to create a semaphore array in java and initialize all semaphores to 1. I tried the following: private static Semaphore [] sem = new Semaphore [] {1,1,1,1,1};
But i get the error Type mismatch: cannot convert from int to Semaphore. How can i do this? I do not want to first declare and then initialize, it must be initialized when declared.
Thanks in advance
You are putting
intvalues into aSemaphorearray, hence the type mismatch. You need