Skip to content

Instantly share code, notes, and snippets.

@phl0w
Created July 13, 2012 18:15
Show Gist options
  • Select an option

  • Save phl0w/3106418 to your computer and use it in GitHub Desktop.

Select an option

Save phl0w/3106418 to your computer and use it in GitHub Desktop.
public class Letters {
public static void main(String[] args) {
printAllLetters(3); //2 for 2 letters, 3 for 3 letters
}
public static void printAllLetters(int length) {
if (length == 2) {
for (char c = 'A'; c <= 'Z'; c++) {
for (int i = 0; i <= 26; i++) {
System.out.println(Character.toString(c) + i);
}
}
} else {
for (char c = 'A'; c <= 'Z'; c++) {
for (int i = 0; i <= 9; i++) {
for (char t = 'A'; t <= 'Z'; t++) {
System.out.println(Character.toString(c) + i + Character.toString(t));
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment