Android examples for java.util:Random String
Returns a random letter [ a-z A-Z ].
//package com.java2s; import java.util.Random; public class Main { /**/* w ww .j a va 2s . c om*/ * Returns a random letter [ a-z A-Z ]. */ public static char randomLetter() { if (Math.random() < 0.5) { return randomLetterLcase(); } else { return randomLetterUcase(); } } /** * Returns a random lower case letter [ a-z ]. */ public static char randomLetterLcase() { Random r = new Random(); return (char) (r.nextInt(26) + 'a'); } /** * Returns a random upper case letter [ A-Z ]. */ public static char randomLetterUcase() { Random r = new Random(); return (char) (r.nextInt(26) + 'A'); } }