wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A question about arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A question about arrays" Watch "A question about arrays" New topic
Author

A question about arrays

Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Hi all!
Take a look at the following code:

Now - I know you get an error when you try to intialize the arrays e and f. But I havn't found any explenation for it. If we f.eg. take a look at array b and e, then the way they intialize the arrays look rather similar.
Does anyone know why this isn't possible ?
Thanks in advance
/Svend Rost
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
The simple answer would be to say that this is because the grammar of the Java language does not allow an array initializer to appear anywhere else than after an array declaration (or creation) expression.
Please check out JLS 10.6 Array Initializers and JLS 15.10 Array Creation Expressions


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Thanks for the quick answer
I'll dig right into it.
/Svend Rost
 
 
subject: A question about arrays
 
Similar Threads
Sun Cirtification
Array Initilization
Question of Arrays.asList()
multi-dimensional array question
Simple J2SE 5.0 Tiger Notes