File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about arrays

 
Svend Rost
Ranch Hand
Posts: 904
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Svend Rost
Ranch Hand
Posts: 904
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick answer
I'll dig right into it.
/Svend Rost
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic