aspose 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 Meteor in Action this week in the JavaScript 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: 42955
    
  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: 41848
    
  31
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.

 
Consider Paul's rocket mass heater.
 
subject: As far as I can see, I have a ']'