This week's book giveaway is in the Design forum. We're giving away four copies of Building Microservices and have Sam Newman on-line! See this thread for details.

I am trying to write a java method which takes a hashmap as the input. The hashmap looks as follows:

Key Value **** ****** Q1 V11,V12,V13,V14....V1n (This is a collection) Q2 V21,V22,V23,V24....V2n (This is a collection) . . . . Qm Vm1,Vm2,Vm3,Vm4....Vmn (This is a collection)

The method should process the hashmap and make all possible combinations as follows:

I am not totally sure what it is you want here, but what ever it is, it sounds really expensive with an operation that will probably border on O(n^2) complexity. The larger your hashmap and the larger the collections contained within that hashmap, the longer it is going to take to process the probabilities.

Can you be a little more clear as to what you are trying to do?