I have to two lists, one named keys for example {a,b,c,d} and the other one named values for example {e,f,g,h}, for simplicity I've written just elements [a-d] and [e-h] but in practice the lists can be of any length altough always the two lists will have the same amount of items.(for example keys {a...z} values {0...25})
List<Character> keys = new ArrayList<Character>();
keys.add('a');
keys.add('b');
keys.add('c');
keys.add('d');
List<Character> values = new ArrayList<Character>();
values.add('e');
values.add('f');
values.add('g');
values.add('h');
I need to create hashMaps objects one by one containig exactly one combination of all the keys and all the values, so for example: one hashMap would be
HashMap<Character,Character> keys_values = new HashMap<Character,Character>();
keys_values.put(keys.get('a'), values.get('e'));
keys_values.put(keys.get('b'), values.get('f'));
keys_values.put(keys.get('c'), values.get('g'));
keys_values.put(keys.get('d'), values.get('h'));
Then in a different hashMap I need to store a different combination for example:
keys_values.put(keys.get('a'), values.get('h'));
keys_values.put(keys.get('b'), values.get('e'));
keys_values.put(keys.get('c'), values.get('f'));
keys_values.put(keys.get('d'), values.get('g'));
And so on.. so for this example of 4 items there should be 4! different hashMaps (I think!) , and each of them with one combination of the elements.
I've thought about doing two nested for loops, but this doesnt give me the results that I'm looking for, because I get several objects with the same key inside the same hashmap.