Android Random Int Create getRandomId()

Here you can find the source of getRandomId()

Description

get Random Id

Declaration

public static String getRandomId() 

Method Source Code

//package com.java2s;

import java.util.Random;

public class Main {
    private static Random rm = new Random();
    private static String chartable[] = { "a", "A", "b", "B", "c", "C",
            "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", "J", "j",
            "K", "k", "L", "M", "m", "N", "n", "P", "p", "Q", "R", "T",
            "t", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

    public static String getRandomId() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 6; i++) {
            sb.append(chartable[getRandomIntNum(chartable.length)]);
        }/*from  w  ww .  j a  v a2s .  c o  m*/
        return sb.toString();
    }

    private static int getRandomIntNum(int limit) {
        return rm.nextInt(limit);
    }
}

Related

  1. nextRandInt(int max)
  2. nextRandInt(int min, int max)
  3. getRandom(int from, int to)
  4. getRandomIntNum(int limit)
  5. getRandom(int from, int to)
  6. random(int min, int max)
  7. randomInt(int low, int high)