Skip to content

Instantly share code, notes, and snippets.

@gavinmyers
Created May 14, 2012 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavinmyers/2691298 to your computer and use it in GitHub Desktop.
Save gavinmyers/2691298 to your computer and use it in GitHub Desktop.
Java Random Letters
package test;
public class Test {
private static String alphabet = "abcdefghijklmnopqrstuvwxyz";
public static void main(args[]) { //haven't written main in awhile... pretty sure this is wrong
int limit = 100; //hard coding since I dont remember how to work with args
int iteration = 3; //every third number
int count = iteratin;
for(int i = 0; i < limit; i++) {
count--;
if(0 >= count) {
count = iteration;
//oh hell...
int r = (int)(Math.random() * 26); //forgot how to get a random number!
String c = Test.alphabet.substr(r, r+1); //I want to cut out that one letter... right??
System.out.println(c);
}
}
}
}
public class Test {
private static String alphabet = "abcdefghijklmnopqrstuvwxyz";
public static void main(String[] args) {
int limit = 100; //hard coding since I dont remember how to work with args
int iteration = 3; //every third number
int count = iteration;
for(int i = 0; i < limit; i++) {
count--;
if(0 >= count) {
count = iteration;
//oh hell...
int r = (int)(Math.random() * 26); //forgot how to get a random number!
String c = Test.alphabet.substring(r, r+1); //I want to cut out that one letter... right??
System.out.println(c);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment