that code is wrong because s is an array variable and to initialise arrays u use the array index which in java is index zero. got it.
String[] s = {"n", "u", "any"};
works because this indexing understood by your compiler but
s = {"n", "u", "any"}; will not be understood by your compiler because, 1. there is no index to signify this is an array, 2. if you index it this late, what index will the compiler look up for?
maybe try:
s[1] = "n";
s[2] = "u";
got it.
that code is wrong because s is an array variable and to initialise arrays u use the array index which in java is index zero. got it.
String[] s = {"n", "u", "any"};
works because this indexing understood by your compiler but
s = {"n", "u", "any"}; will not be understood by your compiler because, 1. there is no index to signify this is an array, 2. if you index it this late, what index will the compiler look up for?
maybe try:
s[1] = "n";
s[2] = "u";
got it.
It has nothing to do with indexes whatsoever. See my previous reply.
No offense meant but like many of your replies, this one is again wrong. Perhaps it it a good thing to first check the things you post. You could've easily verified that there's nothing wrong with the line:
[CODE=java]String[] array = {"Fu", "Bar"};[/CODE]
If you post something wrong, a beginning programmer might take your word for it and gets side tracked by your false claims.
If I post sometthing I'm not 100% sure of it is true, I either do not post it, or I tell the OP that I am not 100% sure about my claims. That way s/he knows to be carefull with the information provided.
Comment