[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:Yes example.length returns the size of the first array. example[0].length returns the size of the inner array. (Make sure your array isn't empty before calling this.)
As for the nested loop, the outer loop runs twice. The inner loop runs three times for each run of the outer loop. 2x3 = 6 so the inner loop runs 6 times.
Campbell Ritchie wrote:You should not use parallel arrays. It is very easy to get the elements of the two out of step. You should have a Synth object with name and price fields, and create a Synth[] array.
Yes. Two arrays with three elements each.Mike Philips wrote: . . . so in this example there are two arrays - . . .
each of these arrays / rows is three sections / elements / columns in length? (I'm not sure what the nomenclature is for this...)
That would mean one of the two arrays inside the larger array.I'm not really following you what you mean by the inner array, as far as I can picture they are parallel - what would an inner array be?
As for the nested loop, the outer loop runs twice. The inner loop runs three times for each run of the outer loop. 2x3 = 6 so the inner loop runs 6 times.
It is just about always better to create a class. Yes, but the fields should be private, initialised via a constructor, and access can be made via getters and maybe also setters. Also a toString method.Mike Philips wrote:. . . it would be better to create a SynthProperties class . . . include some data for it :
like this?
Campbell Ritchie wrote:
It is just about always better to create a class. Yes, but the fields should be private, initialised via a constructor, and access can be made via getters and maybe also setters. Also a toString method.Mike Philips wrote:. . . it would be better to create a SynthProperties class . . . include some data for it :
like this?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |