• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Douglas Knapp
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Throws an error, "']' expected"

Can anyone point out why?

Thank you.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Ulf
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic