Advertisement
Guest User

Untitled

a guest
Sep 8th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. public class Generator {
  2.     private char[] charset;
  3.  
  4.     public Generator()
  5.     {
  6.         charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
  7.     }
  8.  
  9.  
  10.     public void generate(String str, int pos, int length)
  11.     {
  12.         if (length == 0) {
  13.             System.out.println(str);
  14.         } else {
  15.             for (int i = pos; i < charset.length; i++) {
  16.                 generate(str + charset[i], i, length - 1);
  17.             }
  18.         }
  19.     }
  20.  
  21.     public static void main(String[] args)
  22.     {
  23.         Generator test = new Generator();
  24.         //test.generate("", 1);
  25.         for (int length = 0;  length < 5; length++) // Change 5 with the length of charset
  26.             test.generate("", 0, length);
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement