Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Generator {
- private char[] charset;
- public Generator()
- {
- charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
- }
- public void generate(String str, int pos, int length)
- {
- if (length == 0) {
- System.out.println(str);
- } else {
- for (int i = pos; i < charset.length; i++) {
- generate(str + charset[i], i, length - 1);
- }
- }
- }
- public static void main(String[] args)
- {
- Generator test = new Generator();
- //test.generate("", 1);
- for (int length = 0; length < 5; length++) // Change 5 with the length of charset
- test.generate("", 0, length);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement