Mapping of variables to values (permutation with repetition?)

I would be very grateful to anyone who can give me a basic idea on how to solve the following problem because I am stuck at the moment. (and unfortunately swamped with work and unable to take my time and think about it !!!).

I have a set of variables x1,...,xn. The number of the variables is not fixed.

Each variable has a different domain of distinct values

x1 -> {vx11,...,vx1m} , |dx1|=m

.

.

.

xn -> {vxn1,...,vxnk} , |dxn|=k

The domains do not have equal length.

I want to take all the different assignments of values to

variables.

The number of the possible different assignment is of course |dx1|*|dx2|*...*|dxn|. Basically, it is permutation of distinct objects with repetition (?).

So, if for example I have three values x1, x2, x3

x1 : {1,2}

x2 : {1,2,3}

x3 : {5,6}

The number of possible assignments will be 2*3*2 = 12.

x1 x2 x3

1 1 5

1 1 6

1 2 5

1 2 6

1 3 5

1 3 6

2 1 5

2 1 6

2 2 5

2 2 6

2 3 5

2 3 6

I want to implement in Java a solution that produces all different assignments in the most efficient way possible.

For three variables it would probably take three for loops

but here the number of variables is not predefined. It is given as input every time. Any good ideas? I am sorry if the question is idiotic but I have been working 16 hours a day lately and my brain is stuck at the moment!! Thanks in advance!