package com.java.examples.digui;
public class AllOrderOfString {
public static void allOrder(String str){
if(str != null && !str.trim().equals("")){
permuteString("",str);
}
}
private static void permuteString(String beginningString, String endingString) {
if (endingString.length() == 1)
System.out.println(beginningString + endingString);
else
for (int i = 0; i < endingString.length(); i++) {
String newString = endingString.substring(0, i)
+ endingString.substring(i + 1);
permuteString(beginningString + endingString.charAt(i),
newString);
}
}
public static void main(String[] args) {
AllOrderOfString.allOrder("han");
}
}
递归列出一个String串中所有字母的所有可能的排列
最新推荐文章于 2020-10-31 18:48:25 发布