for (int a = 1; a <= 9; a++) { for (int b = 1; b <= 9; b++) { if (b != a) { for (int c = 1; c <= 9; c++) { if (c != a && c != b) { for (int d = 1; d <= 9; d++) { if (d != a && d != b && d != c) { arr.add(""+a+b+c+d); } }}}} } }}
大概思路就是这样,我有点忙,没时间给你写完整的了