Java tutorial
//package com.java2s; public class Main { private static final String RANDOMS = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; public static String getRandom(int num) { StringBuffer sbf = new StringBuffer(); for (int i = 0; i < num; i++) { int random = (int) (Math.random() * (RANDOMS.length())); sbf.append(RANDOMS.charAt(random)); } return sbf.toString(); } }