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 Java 8 in Action this week in the Java 8 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: 24


Throws an error, "']' expected"

Can anyone point out why?

Thank you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
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.)


Ping & DNS - updated with new look and Ping home screen widget
Douglas Knapp
Greenhorn

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

Joined: Oct 13, 2005
Posts: 36579
    
  16
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: 24
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: As far as I can see, I have a ']'
 
Similar Threads
First Java attempt alone - Graph help!
Questions abt Initializer block
Anagrams
Error when using new ForkJoin feature
Why does getSize() need to be inside Canvas's paint method?