A simple piece of code for calculating all permutations of a given word:
public static Listpermutations(String s) { List list = new ArrayList<>(); permutations(list, s, ""); return list; } private static void permutations(List list, String from, String to) { if (from.isEmpty()) { list.add(to); } else { for (int i = 0; i < from.length(); i++) { permutations(list, new StringBuilder(from).deleteCharAt(i).toString(), to + from.charAt(i)); } } }