Best data Structure for storing a phone keypad format I was trying to code the phone keypad characters with its numbers. The first idea which came to my mind is using a HashMap. After trying various options I came up with the below Code. I want to know if the data structure and methodology which I implemented is good or does it need some more improvements.
Things which I know and don't want to implement:

I do not want to hardcode the keypad. I know that there are various ways of implementing a hardcoded keypad. I visited this and this link to learn about other ways.
I would really be thankful if the solution is given in java 7 syntax. I don't have much idea about java 8 syntax, but it'll be helpful to know the solution in that too, if possible.

Keypad feature according to my problem statement:

0 and 1 buttons are not functional.
7 and 9 buttons contain 4 letters each and others contain 3 letters each.

public static void keypadDemo(){
        int ax = 97; // I need to store lower-case letters so took this
        Map&lt;Integer, ArrayList&lt;Character&gt;&gt; hm = new HashMap&lt;&gt;(); // This is my data-structure
        for(int i = 0; i &lt; 10; i++){
            if(i == 0 || i == 1){
                hm.put(i, null); // 0 and 1 keys are not functional as per my problem statement.
            }else if(i == 7 || i == 9){
                hm.put(i, new ArrayList&lt;&gt;(Arrays.asList((char) ax, (char) ++ax, (char) ++ax, (char) ++ax)));
                ax++;
            }else{
                hm.put(i, new ArrayList&lt;&gt;(Arrays.asList((char) ax, (char) ++ax, (char) ++ax)));
                ax++;
            }
        }
       System.out.println(hm);
    }

Any help will be welcomed. Thanks
EDIT:
Keypad format:

The problem statement:

We are given two inputs:

A phone number in string format.
A list of strings.


The output is the list containing only those strings which correspond to any substring of the given phone number when converted to the corresponding letters on the phone keypad.

Example test case:


Input: 
3662277
words = [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;, &quot;emo&quot;, &quot;foobar&quot;, &quot;cap&quot;, &quot;car&quot;, &quot;cat&quot;]

Output: 
outputList = [&quot;foo&quot;, &quot;bar&quot;, &quot;foobar&quot;, &quot;emo&quot;, &quot;cap&quot;, &quot;car&quot;]


I coded the solution and it got accepted too by online judge. But since, I'm learning about Collections in java so wanted to know whether my choice of the data structure is good or not.
It's not possible to say if this method is a good or useful abstraction without context which you have not provided. Accordingly, this review is of the method by itself.
My primary concern with this method is that it is hard to read and understand. Complexity leads to bugs, and should be avoided where possible. This method is doing a simple thing in a complex way. Readers have to worry about a loop and three branches instead of a simple, static mapping.
keypadDemo() should return the Map, not print it. Let the client decide what to do with it.
ax and hm are very poor variable names. Variable names should clearly indicate the value they hold.
Using an integer to magically act as characters makes the method harder to read.
Use the most appropriate abstraction. Map&lt;Integer, List&lt;Character&gt;&gt; would be preferable. The type of list is an implementation detail.
A loop is the wrong structure to build this map. The code is hard to read, which means it's easy to introduce bugs and hard to notice them.
Short-circuiting the loop might make it easier to read.
Empty lists would be better than using null. It's easier to write code that correctly handles an empty list than to special-case null checks.
In idiomatic Java, there is whitespace before a { and after a }. There is whitespace after a for, if, etc.
If I were to need this method in my own code, it would look like: (untested)
/**
 * Generates a mapping from digits on a telephone keypad to the letters for 
 * digit. The letters are in alphabetical order. Digits with no letters
 * map to an empty list. 
 */
public static Map&lt;Integer, List&lt;Character&gt;&gt; digitsToCharacters() {
    Map&lt;Integer, List&lt;Character&gt;&gt; digitsToCharacters = new HashMap&lt;&gt;();
    digitsToCharacters.put(0, Arrays.asList());
    digitsToCharacters.put(1, Arrays.asList());
    digitsToCharacters.put(2, Arrays.asList('a', 'b', 'c'));
    digitsToCharacters.put(3, Arrays.asList('d', 'e', 'f'));
    digitsToCharacters.put(4, Arrays.asList('g', 'h', 'i'));
    digitsToCharacters.put(5, Arrays.asList('j', 'k', 'l'));
    digitsToCharacters.put(6, Arrays.asList('m', 'n', 'o'));
    digitsToCharacters.put(7, Arrays.asList('p', 'q', 'r', 's'));
    digitsToCharacters.put(8, Arrays.asList('t', 'u', 'v'));
    digitsToCharacters.put(9, Arrays.asList('w', 'x', 'y', 'z'));
    return Collections.unmodifiableMap(digitsToCharacters);
}