Return to Snippet

Revision: 46983
at May 28, 2011 09:40 by ehrenb


Initial Code
import java.util.Random;

public class ExtRandom extends Random {


private String output = "";

public String nextLetter() {

switch (nextInt(26)) {
case 0: output = "a"; break;
case 1: output = "b"; break;
case 2: output = "c"; break;
case 3: output = "d"; break;
case 4: output = "e"; break;
case 5: output = "f"; break;
case 6: output = "g"; break;
case 7: output = "h"; break;
case 8: output = "i"; break;
case 9: output = "j"; break;
case 10: output = "k"; break;
case 11: output = "l"; break;
case 12: output = "m"; break;
case 13: output = "n"; break;
case 14: output = "o"; break;
case 15: output = "p"; break;
case 16: output = "q"; break;
case 17: output = "r"; break;
case 18: output = "s"; break;
case 19: output = "t"; break;
case 20: output = "u"; break;
case 21: output = "v"; break;
case 22: output = "w"; break;
case 23: output = "x"; break;
case 24: output = "y"; break;
case 25: output = "z"; break;

}

return output;
}
}

Initial URL


Initial Description
I did not code this, but it is a very handy, and easy-to-understand class which uses the random number generator to generate a random letter.

Initial Title
Random Letter Class

Initial Tags


Initial Language
Java