• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Throws an error, "']' expected"

Can anyone point out why?

Thank you.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Ulf
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic