1. // str 固定参数
    2. // 来到了str[index]字符,index是位置
    3. // str[0..index-1]已经走过了!之前的决定,都在path上
    4. // 之前的决定已经不能改变了,就是path
    5. // str[index....]还能决定,之前已经确定,而后面还能自由选择的话,
    6. // 把之前所有生成的子序列,放入到ans里去
    7. public static void process1(char[] str, int index, List<String> ans, String path) {
    8. if (index == str.length) {
    9. ans.add(path);
    10. return;
    11. }
    12. // 没有要index位置的字符
    13. process1(str, index + 1, ans, path);
    14. // 要了index位置的字符
    15. process1(str, index + 1, ans, path + String.valueOf(str[index]));
    16. }