If it's a primitive type, you can use Arrays.fill():
Arrays.fill(array, -1);
[Incidentally, memset in C or C++ is only of any real use for arrays of char.]
initializing arrays - Processing 2.x and 3.x Forum
Phil the Java Noob - Help on declaring/initializing arrays
How to initialize all elements in an array to 0
[Java] Question about initializing all elements in an array to a specific given number.
Videos
Me yet again! Arrays are really kicking my ass haha, can't seem to grasp them all that well.
Have a (seemingly) very basic question in regards to arrays:
" Return an int array length 3 containing the first 3 digits of pi, {3, 1, 4}."
What I have is this:
"public int[] makePi() {
int [3] arr;
int [1] arr;
int [4] arr;
}"
Can one of you kind souls explain to me what place(s) I'm going wrong? MOREOVER, can someone give me a brief rundown on how one declares arrays? Admittedly, my resources that I'm learning from aren't the best at explaining some concepts.
As always, thank you very much!!