• 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

array woes

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a little code sniplet to get you to the right path...
 
Sam Smythe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK... take a look at this
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.)
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic