We are about to switch to a new forum software. Until then we have removed the registration on this forum.
When I enter something like this:
int[] list = {0,0,0};
list = {1,0,0};
I get the error message: unexpected token: {
How do I reassign everything in an array. I could not find the answer to this in a search/ didn't know how to search for it.
Answers
;-)
or in using a for-loop when we have mostly the same number or there's a formula we can use
;-)
In Java, shortcut array instantiation w/ just
{}
is only valid when we're also declaring a variable for it.Re-assignment demands
new
+ explicit array type before the{}
: :(Ha! Great. I didn't know this! Thank you. ;-)
Thanks guys!
I was using the first solution you gave me Chrisir, but was looking for something a bit cleaner. Glad to know I can change t