File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array[] [] ?

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See anything wrong here?



Output: Tool completed with exit code 2
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Greg Brannon
Bartender
Posts: 563
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your line:

int[] [] magicNumbers = new int[] [];

Is an incomplete declaration/creation of the array. Why?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And:is incorrect - the bit in < > must be a type, not a variable.
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:And:is incorrect - the bit in < > must be a type, not a variable.





Output
C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\TestSeven.java:15: illegal start of type
for (int x = 0; x < 10; x++)
^
C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\TestSeven.java:15: illegal start of type
for (int x = 0; x < 10; x++)
^
C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\TestSeven.java:15: <identifier> expected
for (int x = 0; x < 10; x++)
^
C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\TestSeven.java:23: illegal start of type
for (int x = 0; x < 10; x++)
^
C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\TestSeven.java:23: illegal start of type
for (int x = 0; x < 10; x++)
^
C:\Documents and Settings\Jon\workspace\JavaDev\myCode Snippets\TestSeven.java:23: <identifier> expected
for (int x = 0; x < 10; x++)
^
6 errors

Tool completed with exit code 1


NOTE: By the way the copy to clipboard option on this forum does not seem to work with my laptop, I am using Google Chrome.

 
Greg Brannon
Bartender
Posts: 563
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An equivalent declaration/creation and initialization of your array would have been:



Did you mean to write your code inside a method? Maybe a main() method? It doesn't have to be main(), but it should be in a method.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot put arbitrary statements like "for" at class level. Those statements must be inside a constructor or method.

Jon Camilleri wrote:NOTE: By the way the copy to clipboard option on this forum does not seem to work with my laptop, I am using Google Chrome.

Workaround: Click "view plain" instead of "copy to clipboard", then select the text in the popup window and copy it with Ctrl+C.
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:You cannot put arbitrary statements like "for" at class level. Those statements must be inside a constructor or method.

Jon Camilleri wrote:NOTE: By the way the copy to clipboard option on this forum does not seem to work with my laptop, I am using Google Chrome.

Workaround: Click "view plain" instead of "copy to clipboard", then select the text in the popup window and copy it with Ctrl+C.



lol, how could I forget to create a method() that Java actually looks into for executing code, btw is '...' considered valid for passing arguments?


 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "..." is called varargs, one of the new features of Java 5.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic