public static void combinations(String s) {
char[] original = s.toCharArray();
int original_size = s.length();
String temp = new String();
for (int i = 0; i < original_size; i++) {// add the first element
String sb = "";
temp = "";
sb = "" + original[i];
temp = sb.toString();
System.out.println(sb);
for (int j = i + 1; j < original_size; j++) {// add the other
// element in the
// array
if (i == j)
continue;
sb = temp + "" + original[j];
System.out.println(sb);
}
// sb = "";
}
}
public static void main(String[] args) {
combinations("abc");
}
结果应该是:a,ab,ac,abc,b,bc,c
但我的程序是:a、ab、ac、b、bc、c。我无法打印 abc