Here you can find the source of randomWord(int wordLength)
private static String randomWord(int wordLength)
//package com.java2s; public class Main { private final static String WORD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; /**/*w ww .ja va 2 s .co m*/ * @return CAPTCHA word */ private static String randomWord(int wordLength) { StringBuffer word = new StringBuffer(); for (int i = 0; i < wordLength; i++) { int index = Math.abs((int) (Math.random() * WORD.length())); char ch = WORD.charAt(index); word.append(ch); } return word.toString(); } }