I need this to try every ables[z] and the move on to another check. How can i check if its finished without finding the right word in the ables against the other array. Or if its finished and has found the word.

for(int i = 0; i < array1.length; i++)
{
for(int z = 0; z < ables.length; z++)
                {
                    if(array1[i][0].equals(ables[z].getWord()))   
                    {
for(int z = 0; z < consumables.length; z++)                {                    if(Array[i][0].equals(ables[z].getWord()))

i''m not sure how ables max index or top relates to consumables.length.
if ables went to 10 you would want to loop from 0-9 not consumables.length so maybe ables.length instead

Mike

you have the same issue on the outer loop, Array[0]

your i loop should go to Array.length since your trying to loop through its values from min to max. Are you using the right name there for what you want? Array[0]?

Mike

haha sorry thats my bad i've editted it now, just messed up the array identifiers, i got two classes mixed up.

But the question stands!

you have the same issue on the outer loop, Array[0]

your i loop should go to Array.length since your trying to loop through its values from min to max. Are you using the right name there for what you want? Array[0]?

Mike

maybe something got lost in the translating. looks like your i array is array1. since its two dimenstional you 'll want to know the max value of the dimension you are counting. since its declared obviously somewhere, store that value in something and use that as your for loop limiter similar to length

well ables.lenght should work fine but i think the point i brought up about your two dimensional array is still an issue.

if you have a max on [x][y] maybe store xmax and ymax around time of declaration. total storage is xmax * ymax.

Mike

sometimes arrays are not filled up. thats when you need to track the top. i..e int ables = new int[100];

but you cant do ables[10].getword();

if you havent written data to ables[10].

how that is handles depends on how ables is populated. if ables[0] is written to then ables[1] then ables[2] you keep a variable called something like top typically. every time you add then ablesTop++;

If its populated randomly maybe a sister array of 1s and 0s so

int ables = new int[100];
int ablesUses = new int[100];

for(int a=0; a < ablesUses.length; a++)
ablesUses[a]=0;

and add at spot 39 is

ables[39]= something;
ablesUses[39]=1; // you turn know spot 39 is active.

What you are getting into is how you represent data. it's a job managing in its own right.
Mike

I'm sorry guys im still learning, so what im basically trying to do is i need to check one element of array1 against all of array2, until i find a match(in which case i add to the total) or I find a certain element that sums the total and start from 0 again. Or finally it could just not be in there.

So i need to check [0] of array1 against all of array2

and the check the [1] of array 1 against all of array2

how can i do that?

if i had array a[10][20]
and array b[15]

and i wanted to check all of array b against array a or vice versa i need 3 loops.

my 2 dimmensional array i need to know the dimension 1 max and the dimension 2 max. i.e. 10 and 20

b.length will work for the third inner loop. if bi is not filled i ned to track b's top. ie b[100] but b only has 10 values, each time i add btop++ and btop = 10 now. use that as my third limiter not b.length

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.