This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Greenhorn
Posts: 28
IntelliJ IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Throws an error, "']' expected"

Can anyone point out why?

Thank you.
 
Rancher
Posts: 42975
76
  • 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: 28
IntelliJ IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Ulf
 
Marshal
Posts: 58421
178
  • 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: 28
IntelliJ IDE VI Editor
  • 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.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!