zoukankan      html  css  js  c++  java
  • 自动生成不重复的含有数字和字母的随机码

    /**
    * 随机代码生成,长度不超过36
    * 自动生成不重复的含有数字和字母的随机码
    */
    package src;

    import java.util.ArrayList;

    public class Test {

            public static void main(String[] args) throws IndexOutOfBoundsException {
                    ArrayList list = new ArrayList();
                    // list.add(1);
                    for (int i = 0; i < 10; i++)
                            list.add(i);

                    for (char c = 'a'; c <= 'z'; c++)
                            list.add(c);
                    /*for (int i = 0; i < list.size(); i++) {
                            System.out.println(list.get(i));
                    }*/
                    for (int i = 0; i < Math.random()*36+1; i++) {
                            int mathInt;
                            mathInt=(int) (Math.random()*list.size());
                            System.out.print(list.get(mathInt));
                            list.remove(mathInt);
                    }
            }
    }
  • 相关阅读:
    github添加ssh
    包围盒的计算以及物体移动到世界坐标中心
    123
    mysql
    建站步骤
    深度遍历和广度遍历
    Js特殊字符转义之htmlEscape()方法
    参数命名风格转换
    http 206
    js 实现快速排序
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2007691.html
Copyright © 2011-2022 走看看