Created
May 14, 2012 02:03
-
-
Save gavinmyers/2691298 to your computer and use it in GitHub Desktop.
Java Random Letters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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