File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes As far as I can see, I have a ']' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "As far as I can see, I have a Watch "As far as I can see, I have a New topic
Author

As far as I can see, I have a ']'

Douglas Knapp
Greenhorn

Joined: Feb 14, 2012
Posts: 26


Throws an error, "']' expected"

Can anyone point out why?

Thank you.
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
You can declare variables outside of methods (as in line 4), but you can't put assignments (lines 7 to 16) outside of methods. Move those into a non-static method and it should work. (Note I said "non-static" - main is static, so unless you make xArray static as well it won't work inside of main.)
Douglas Knapp
Greenhorn

Joined: Feb 14, 2012
Posts: 26
Thank you, Ulf
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40476
    
  28
Try this:-I can see at least one more thing which will go wrong, however

I challenge you to tell me what it is, before you run that code. I also challenge you to work out how you can pass that array as “args”.
Douglas Knapp
Greenhorn

Joined: Feb 14, 2012
Posts: 26
Campbell Ritchie wrote:I can see at least one more thing which will go wrong, however

I challenge you to tell me what it is, before you run that code. I also challenge you to work out how you can pass that array as “args”.


Campbell,
I didnt't see your reply before I tried to run it. "Hmm... Why is it printing numbers..."
Figured it out.

I'm working on the whole passing an array thing now. Thank you.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: As far as I can see, I have a ']'