2014-02-13 61 views

回答

0
public class Demo { 

    public static void main(String[] args) { 

     String str = "ABCD"; 
     String prefix = ""; 
     combination(prefix, str); 
    } 

    public static void combination(String prefix, String str) { 

     System.out.println(prefix); 

     for (int i=0; i<str.length(); ++i) 
      combination(prefix + str.charAt(i), str.substring(i+1)); 

    } 

}