Letter combinations of phone dial pad number
Putting the members of this class in the reverse order (map, then letterCombinations(), then main()) would be more customary.  The map should be private unless you have a good reason to do otherwise.  I would also avoid creating an anonymous subclass of HashMap, and initialize it this way:

private static final HashMap&lt;Character, String&gt; map = new HashMap&lt;&gt;(8);
static {
    map.put('2', "abc");
    map.put('3', "def");
    map.put('4', "ghi");
    map.put('5', "jkl");
    map.put('6', "mno");
    map.put('7', "pqrs");
    map.put('8', "tuv");
    map.put('9', "wxyz");
};




It would be more obvious that preres is a temporary variable if you scoped it properly.  Both res and preres could be named better — I've chosen results and nextResults, respectively.

Whenever possible, you should specify the initial capacity of an ArrayList.  The penalty for underestimating can be rather severe, as it requires reallocating and copying existing results.

digits.charAt(i) is a loop invariant that can be moved from the middle loop into the outer one.

All loops should have braces.  Omitting them is bad practice and will cause maintenance-induced bugs.

public static List&lt;String&gt; letterCombinations(String digits) {
    List&lt;String&gt; results = new ArrayList&lt;String&gt;();
    results.add("");

    for (int i = 0; i &lt; digits.length(); i++) {
        String letters = map.get(digits.charAt(i));
        List&lt;String&gt; nextResults = new ArrayList&lt;&gt;(letters.length() * results.size());
        for (String str : results) {
            for (int j = 0; j &lt; letters.length(); j++) {
                nextResults.add(str + letters.charAt(j));
            }
        }
        results = nextResults;
    }
    return results;
}




It's generally better to return List&lt;String&gt; rather than ArrayList&lt;String&gt;, to give you flexibility to change the implementation.  For example, here is a solution that uses just one LinkedList.

public static List&lt;String&gt; letterCombinations(String digits) {
    LinkedList&lt;String&gt; results = new LinkedList&lt;&gt;();
    results.add("");

    for (int i = 0; i &lt; digits.length(); i++) {
        String letters = map.get(digits.charAt(i));
        for (int j = results.size(); j &gt; 0; j--) {
            String intermediateResult = results.poll();
            for (int k = 0; k &lt; letters.length(); k++) {
                results.add(intermediateResult + letters.charAt(k));
            }
        }
    }
    return results;
}