import java.util.*; public class Test { private final static char[] chars; private final static Random random; static { chars = new char[52]; for (int i = 0; i < 26; i ++) { chars[i] = (char) (97 + i); chars[i + 26] = (char) (65 + i); } random = new Random (); } public static void main (String[] args) { System.out.println (randomString (5)); } // int random = (int)(Math.random()*40); // int random = new java.util.Random().nextInt(40); private static String randomString (int length) { //tried to convert into using Math.random instead of having to import // Class RANDOM but MATH uses DOUBLES, and since with // Arrays when setting the # of elements, you must use INT, seems like it'd be //best/only possible?/efficient to use class Random instead of Math.random in //this case? char[] array = new char[length]; for (int i = 0; i < length; i ++) { array[i] = chars[random.nextInt (chars.length)]; } return new String (array); } }