Here you can find the source of permutation(String prefix, String s, List
private static void permutation(String prefix, String s, List<String> list)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { private static void permutation(String prefix, String s, List<String> list) { int n = s.length(); if (n == 0) { list.add(prefix);//from w w w . ja va 2s . co m } else { for (int i = 0; i < n; i++) { permutation(prefix + s.charAt(i), s.substring(0, i) + s.substring(i + 1, n), list); } } } }