What I'm tring to do is to create a HashMap,which looks like this.
I assumed that the wildcard symbol *
can be used as a key, so if any character other than a
,b
and c
(let's say x
) is searched for, this HashMap will return 10
.
for (int j = 0; j <= 2; j++) {
table.put(pattern[j], (pattern.length - 1 - j));
//This part is actually not the same as the original code.
//The keys are a,b,c, and the values are 1,2,3 respectively
}
table.put('*', 10);
However, when I search this map for a key x
, this returns null
, so it is clear that *
can't be directly used as a wildcard key. I followed this page, but apparently this doesn't work for HashMap.
I'd appreciate if you would give any insight to solve this.