public void perm(char[] chs, int start, List<String > res) { if (start == chs.length - 1) { res.add(new String(chs)); } else { for (int i = start; i < chs.length; i++) { swapChs(chs, start, i); perm(chs, start + 1, res); swapChs(chs, start, i); } } } private void swapChs(char[] chs, int i, int j) { char temp = chs[i]; chs[i] = chs[j]; chs[j] = temp; }