find all anagrams of a given word I wrote this program which generates anagrams for a given word.
The init function will create a dictionary of words. it can be read from a text file or array. Here I'm reading words from an array to create my dictionary.
I would like some advice on how to optimize this code or any changes or suggestions needed to improve efficiency of this code is appreciated. 

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Solution {

    static Map&lt;String, ArrayList&lt;String&gt;&gt; dictionaryMap = new HashMap&lt;String, ArrayList&lt;String&gt;&gt;();

    private void addToMap(String key, String word) {
        ArrayList&lt;String&gt; anagramList = dictionaryMap.get(key);

        if (anagramList == null) {
            anagramList = new ArrayList&lt;String&gt;();
            anagramList.add(word);
            dictionaryMap.put(key, anagramList);

        }
        if (!anagramList.contains(word)) {
            anagramList.add(word);
            dictionaryMap.put(key, anagramList);
        }
    }

    private String createMap(String word) {
        Map&lt;Character, Integer&gt; characterCountMap = new HashMap&lt;Character, Integer&gt;();
        StringBuffer buff = new StringBuffer();
        char arr[] = word.toLowerCase().toCharArray();
        Arrays.sort(arr);
        String sortString = Arrays.toString(arr);
        for (int i = 0; i &lt; sortString.length(); i++) {
            char c = sortString.charAt(i);
            if (characterCountMap.containsKey(c))
                characterCountMap.put(c, characterCountMap.get(c) + 1);
            else
                characterCountMap.put(c, 1);
        }

        for (Map.Entry&lt;Character, Integer&gt; entry : characterCountMap.entrySet())
            buff.append(entry.getKey() + entry.getValue());

        return buff.toString();
    }

    private Map&lt;String, ArrayList&lt;String&gt;&gt; init(String[] words) {
        for (String word : words) {
            addToMap(createMap(word), word);

        }
        return dictionaryMap;
    }

    private String[] getAnagrams(String word) {

        String key = createMap(word);
        List&lt;String&gt; al = dictionaryMap.get(key);
        String[] arr = al.toArray(new String[al.size()]);
        return arr;
    }

    public static void main(String[] args) {
        Solution obj = new Solution();
        System.out.println("This is a debug message");
        String arr[] = { "ate", "eat", "THIS", "EAT" };
        obj.init(arr);
        for (String anagram : obj.getAnagrams("tea"))
            System.out.println(anagram);

    }
}
Thanks for sharing your code.

This is what I think about it

General Coding

program against interfaces

Most of your variables are defines as concrete types (classes you actually instantiate). 
You should better declare them as interface types so that it is possible to exchange 
the concrete implementation without changing the code all over.

example

static Map&lt;String, ArrayList&lt;String&gt;&gt; dictionaryMap = new HashMap&lt;String, ArrayList&lt;String&gt;&gt;();


should better be

static Map&lt;String, List&lt;String&gt;&gt; dictionaryMap = new HashMap&lt;String, ArrayList&lt;String&gt;&gt;();


or even

static Map&lt;String, Collection&lt;String&gt;&gt; dictionaryMap = new HashMap&lt;String, ArrayList&lt;String&gt;&gt;();


Problem here is that you need to know what interfaces are available and what the 
consequences are using them. The public API 
is the place to find that information.

Be consistent

Choose the same approach for the same problem

E.g. you use two different types of loops

    for (int i = 0; i &lt; sortString.length(); i++) {
        char c = sortString.charAt(i);
    //...
    // vs.
    for (String word : words) {
        addToMap(createMap(word), word);
    //...


Unless you really need the index variable for something else then accessing the actual 
object in the collection loops over you could (and should) stick to the foreach 
form

    for (char c : sortString.toCharArray()) {


Learn about the capabilities of the objects provided by the runtime

Especially the class Map has some interesting methods your code could benefit from: 
The code

    ArrayList&lt;String&gt; anagramList = dictionaryMap.get(key);
    if (anagramList == null) {
        anagramList = new ArrayList&lt;String&gt;();
        anagramList.add(word);
        dictionaryMap.put(key, anagramList);
    }


could be replaced by

    ArrayList&lt;String&gt; anagramList = dictionaryMap.computeIfAbsent(key,()-&gt;new ArrayList&lt;String&gt;());


If you would know that beside (Array-)List which allows duplicates, the Java 
Runtime provides another collection type Set which does not hold duplicates, then 
you could even get rid of the other if in this method too:

static Map&lt;String, Collection&lt;String&gt;&gt; dictionaryMap = new HashMap&lt;String, Collection&lt;String&gt;&gt;();

private void addToMap(String key, String word) {
    dictionaryMap.computeIfAbsent(key,()-&gt; new HashSet&lt;String&gt;())
                 .add(word);
 }


Avoid arrays

instead of arrays better use Collection types like any implementations of the List 
and  Set interfaces. They are more flexible and prevent you to copy data (yourself) 
when its size needs to be changed.

use the static key word with intention

You declared the variable dictionaryMap as a class variable although it is not 
accessed by any  static method. Unless you understand the consequences you should not use the static key word.

narrow your interfaces

Your method init() has a return value which is not needed since there is no caller 
of this method dealing with this return value. Methods with return value usually 
are harder to refactor. Especially its harder to split them into smaller methods.

Naming

Finding good names is the hardest part in programming, so always take your time to 
think about the names of your identifiers

Please read (and follow) the Java Naming Conventions.

This does not only apply to the casing of the identifiers. 
It also applies to how names are "constructed".
E.g.: you named a method getAnagrams(). 
By conventions the prefix get is reserved for methods, that do not do any processing 
but simply return a property of the object.
But your method does a lot more than that.
Therefore a better name could be findAnagramsOf(String word).

avoid single character names

Since the number of characters is quite limited in most languages you will soon run 
out of names. This means that you either have to choose another character which is 
not so obviously connected to the purpose of the variable. And/or you have to "reuse" 
variable names in different contexts. Both makes your code hard to read and understand 
for other persons. (Keep in mind that you are that other person yourself if you look 
at your code in a few month!)

On the other hand in Java the length of identifier names is virtually unlimited. 
There is no penalty in any way for long identifier names. So don't be stingy with 
letters when choosing names.

Choose your names from the problem domain

Some of your identifiers (or at least parts of them) have technical meaning. 
But your identifiers should convey you business solution. 

example: characterCountMap,  c, sortString or arr.

Remember that the technical details may change while the meaning of your identifiers 
in respect to the business problem will remain.
so this identifiers might better be: 

characterCounts, currentCharacter, sortedCharacters or wordCharacters.