public class pattern { patternAsso's keys are made of values taken from patternStrings3. patternStrings3 is made of p1[hh]+items[mm]+items[nn]. So it will look like "a.* aa", "a.* ab", "a.* ac"... You forgot that p1 values contains a space. What you want to do is :