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
If it's a primitive type, you can use Arrays.fill():
Arrays.fill()
Arrays.fill(array, -1);
[Incidentally, memset in C or C++ is only of any real use for arrays of char.]
memset
char