package com.hanqi; import java.util.*; public class Sanweishu { public static void main(String[] args) { // TODO 自动生成的方法存根 String shu = "1234"; int sum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { String shu1 = shu.replace(shu.substring(i, i + 1), ""); // System.out.println(shu1.length()); for (int k = 0; k < 2; k++) { String shu2 = shu1.replace(shu1.substring(j, j + 1), ""); // System.out.println(shu2.length()); String jieguo = shu.substring(i, i + 1) + shu1.substring(j, j + 1) + shu2.substring(k, k + 1); // 结果输出转换为int sum = sum + 1; System.out.print(" " + new Integer(jieguo)); } } System.out.println(); } System.out.println("一共" + sum + "个数"); } }