|
regardless of the name of your array variable, your code is all wrong:
1) you never use the command line arguments (args) passed to your main method. That's where the number should be passed.
2) You're using an object, input, that's never declared. what is this animal? where did it come from? how is it supposed to get input?
2) You're using a variable, length, that is never declared. Again, what is this, where did it come from?
You can't just make up variables and methods and hope that they'll work. Programming doesn't work that way.
Your solution is to use the args passed to your main method, check to see that an arg was in fact passed (that the array length is > 0), convert the passed String to an int (using a method from the Integer class), and then creating your array with this result.
Last edited by Fubarable; 01-03-2009 at 05:59 AM.
|