Re: Two dimensional Arrays
Quote:
Originally Posted by
masterT
I've posted this on another part of this forum as well but more people are viewing in here :cool:
I think you'll find that multiple posting is not considered cool.
If you want help with nested loops, just ask.
Re: Two dimensional Arrays
I have removed the :cool: ........................................
Should I remove one of the threads as well if its offending you?
Re: Two dimensional Arrays
Quote:
Originally Posted by
masterT
Should I remove one of the threads as well if its offending you?
It doesn't offend me, it's just thoughtless. The mods will probably remove it.
Re: Two dimensional Arrays
Hi dlorde, please forgive me.... Im going a little crazy and I just need help (famous last words!) I'm kinda in a thoughtless mood to be honest and would appreciate any help that you could give me. I know when you see things like this, you probably just want to move onto the next thread but please help. If a mod can remove the other one then ok then but for now if an expert like you can help then please do ^:)^
Re: Two dimensional Arrays
So what are you asking, exactly? The more specific the question, the more specific the answer is likely to be.
If you want help with nested loops, just ask.
Re: Two dimensional Arrays
Ok, so how can I put values from one 2D array into another using a nested loop?
Re: Two dimensional Arrays
If you think of the array in terms of multiple rows, with multiple items in each row (i.e. rows & columns). You write a loop that iterates over the rows, using a row counter, so it deals with one row (array of items) each time round; then inside that loop, you write another loop that takes the current row and iterates over it using a column counter, to access each column (item) in the row. So for each item, you'll have the row index and the column index, so you can copy that item from the 2D source array to the 2D destination array:
destinationArray[rowIndex][columnIndex] = sourceArray[rowIndex][columnIndex];
Don't forget that array indexes start at zero, and be sure that the destination array has been initialized to the correct size.
Re: Two dimensional Arrays
Hi dlorde, I noticed you commented on an exact same problem thread > http://www.javaprogrammingforums.com...n-array-5.html <
So in this case you also mention about a single loop? How can this be done? Do you have any examples? With the 2D boolean array that is mentioned "letter" we dont actually get the elements value, its just returned by LEDFont so that we can use it to over ride matrix...
Sounds pretty stupid, but hey thats our great assignment!
Re: Two dimensional Arrays
Quote:
about a single loop? How can this be done?
The single loop copied a full row at each time around the loop.
A two dim array is made up of a bunch of one dim arrays. For example:
<type>[][] twoDim = new <type>[10][5];
Then
twoDim[0] is a one dim array of <type>[5]
the same for the other indexes from 1 to 9. A total of 10 one dim arrays with 5 elements each.
Re: Two dimensional Arrays