Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

All possible combinations given a 2D Array

843789Jun 18 2010 — edited Jun 18 2010
Hi all,

I have a 2D array String[][] stringarray.
I use the 2D array like this: String [num of items][values of items]. Num of items means the number of unique items, and values of items is its possible values.

I want to find out all the possible combinations of it. For example, given a 2D array with num of items = 3 and value of items = 2:

[0] [0] and [1] [0] and [2] [0]
[0] [0] and [1] [0] and [2] [1]

[0] [0] and [1] [1] and [2] [0]
[0] [0] and [1] [1] and [2] [1]

[0] [1] and [1] [0] and [2] [0]
[0] [1] and [1] [0] and [2] [1]

[0] [1] and [1] [1] and [2] [0]
[0] [1] and [1] [1] and [2] [1]

I currently am using recursion however, I am having difficulty in finding the correct way to do it.

Please help me, this is driving me crazy!

Thank you very much!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2010
Added on Jun 18 2010
7 comments
2,498 views