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);
                    }
            }
    }
  • 相关阅读:
    docker-compose 命令详解
    Ubuntu 安装 rabbitmq
    scrapy.cmdline.execute
    queue.Queue()
    多线程通信
    多线程(thread+queue 售票)
    协程
    线程
    利用Nginx实现反向代理web服务器
    利用Nginx实现反向代理web服务器
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2007691.html
Copyright © 2011-2022 走看看