Java Random Number getRandomNumAndLetterAF(int len)

Here you can find the source of getRandomNumAndLetterAF(int len)

Description

get Random Num And Letter AF

License

Open Source License

Declaration

public static String getRandomNumAndLetterAF(int len) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    public static final String[] NUMSLETTER_A_F = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C",
            "D", "E", "F" };

    public static String getRandomNumAndLetterAF(int len) {
        String s = "";
        s.toCharArray();//from w w  w  .j a  v  a 2 s  .  c  om
        return getRandom(len, NUMSLETTER_A_F);
    }

    public static String getRandom(int len, String[] arr) {
        String s = "";
        if (len <= 0 || arr == null || arr.length < 0) {
            return s;
        }
        Random ra = new Random();
        int arrLen = arr.length;
        for (int i = 0; i < len; i++) {
            s += arr[ra.nextInt(arrLen)];
        }
        return s;
    }
}

Related

  1. getRandomNum()
  2. getRandomNum()
  3. getRandomNum(double pSngBegin, double pSngEnd)
  4. getRandomNum(int len)
  5. getRandomNum(int pwd_len)
  6. getRandomNumAndStr(int length)
  7. getRandomNumber()
  8. getRandomNumber()
  9. getRandomNumber()