In article <96**************************@posting.google.com >,
cy****@hotmail.com says...
Probably a very easy question for most of you guys out there but I
simply can't get to figure out how to do this
Suppose that I have an unknown number of items (A,B,C,etc...) and each
item contain an unknown number of elements(e.g A1,A2,A3,A4, B1,B2, C1)
How would I go around writing a java code to give me the possible
combinations(in that case 8)of A B and C in that order?
i.e.
A1 B1 C1
A1 B2 C1
A2 B1 C1
A2 B2 C2
A3 B1 C1
A3 B2 C2
A4 B1 C1
A4 B2 C2
Help pls
One way is to use two loops. The outer loop steps through the number of
items and the inner loop steps through the elements in each item. If you
cannot programmatically determine the number of items or elements prior
to entering the loop, then an iterator is more useful. Alternatively, you
can place a "sentinel" value (i.e. null) at the end of the list and,
instead of loopping use while (!null){ } .
--
Fuck George W. Bush!!!