代码计算出7890数字排列的成六位数的可能

#算法
代码计算出7890数字排列的成六位数的可能

问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

dfs一下即可

    public static void main(String[] args) {
        List<String> res = new ArrayList<>();
        dfs("7890".toCharArray(), 6, new StringBuilder(), res);
        System.out.println(res.size());
        System.out.println(res);
    }

    public static void dfs(char[] chars, int len, StringBuilder builder, List<String> res) {
        if (builder.length() == len && res.add(builder.toString())) return;
        for (char c : chars) {
            // 剪枝,去除以0开头的
            if (builder.length() == 0 && c == '0') continue;
            builder.append(c);
            dfs(chars, len, builder, res);
            builder.deleteCharAt(builder.length() - 1);
        }
    }