Here you can find the source of getNumbersAndAlphabet()
public static String getNumbersAndAlphabet()
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private final static String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private final static int length = 6; public static String getNumbersAndAlphabet() { Random random = new Random(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { sb.append(getRandomString(random.nextInt(randString.length()))); }/*from w w w. ja va 2s. c om*/ return sb.toString(); } private static String getRandomString(int num) { return String.valueOf(randString.charAt(num)); } }