In C/C++ we have memset() function which can fulfill my wish but in Java how can i initialize all the elements to a specific value? Wh
C/C++
memset()
Java
There's also
int[] array = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
Evidently you can use Arrays.fill(), The way you have it done also works though.
You can use Arrays.fill(array, -1).
Arrays.fill(array, -1)
Have you tried the Arrays.fill function?