Here you can find the source of getRandomNumAndLetterAF(int len)
public static String getRandomNumAndLetterAF(int len)
//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; } }