aspose file tools*
The moose likes Java in General and the fly likes array woes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "array woes" Watch "array woes" New topic
Author

array woes

Sam Smythe
Greenhorn

Joined: Jun 20, 2006
Posts: 12
I am trying to do a 2 dimensional array where size, beginning number and end number are passed in through the parameter. I keep getting an illegal start erro on the first dimension when I try to compile. I left the 2nd dimension as simple integers for now because if I can get the first half working, I can get the second half working. Any suggestions/direction would be appreciated.

bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
You will have to be more specific about what you are trying to achieve.
The code you provided does not compile at all.

Can you explain what this code is supposed to do (it can't work, but I can not figure out what it should do)?
[ February 13, 2007: Message edited by: bart zagers ]
Sam Smythe
Greenhorn

Joined: Jun 20, 2006
Posts: 12
What I am supposed to do is fairly vague, and I think that is the problem. I have pasted it below. I am not yet concerned about the second method. I think I know what to do. It is just getting those parameters to set the size, begininning and end limits, and generate the numbers that get put in the array. I know how to create a 2 dimensional where specific values are passed in. I just don't know how to generate them using those guidelines, then pass them in. Every example I have found involves creating the array and passing in specific, pre-determined values.

Write a method that creates and initializes a two-dimensional array of double. The size of the array is determined by the arguments of the method, and the initialization values are a range determined by beginning and ending values that are also arguments of the method. Create a second method that will print the array generated by the first method. In main(), test the methods by creating and printing several different sizes of arrays.
Anton Uwe
Ranch Hand

Joined: Jan 10, 2007
Posts: 122
Just a little code sniplet to get you to the right path...
Sam Smythe
Greenhorn

Joined: Jun 20, 2006
Posts: 12
That's similar to the examples I have, but is still just creating the array with specific values. What I can't seem to do is generate numbers, from a certain number to a certain number, and make the array an exact size based upon the variable passed through to the parameter.
Anton Uwe
Ranch Hand

Joined: Jan 10, 2007
Posts: 122
OK... take a look at this
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
The size of the array is determined by the arguments of the method


How do you interpret the size of a two-dimensional array? In your example, you give your method a single size parameter.
Take for example a size of 5, how would the resulting array look like?

(Another approach would be to use 2 variables, one for each dimension.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: array woes