Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. public class Core {
  4.  
  5. final int min;
  6. final int max;
  7. final int stringLength;
  8.  
  9. private final int[] chars;
  10.  
  11. public Core(char min, char max, int len) {
  12. this.min = min;
  13. this.max = max;
  14. this.stringLength = len;
  15. chars = new int[stringLength + 1];
  16. Arrays.fill(chars, 1, chars.length, min);
  17. }
  18.  
  19. public void run() {
  20. while(chars[0] == 0) {
  21. print();
  22. increment();
  23. }
  24. }
  25.  
  26. private void increment() {
  27. for(int i = chars.length - 1; i >= 0; i--) {
  28. if(chars[i] < max) {
  29. chars[i]++;
  30. return;
  31. }
  32. chars[i] = min;
  33. }
  34. }
  35.  
  36. private void print() {
  37. for(int i = 1; i < chars.length; i++) {
  38. System.out.print((char) chars[i]);
  39. }
  40. System.out.println();
  41. }
  42.  
  43. public static void main(String[] args) {
  44. new Core('a', 'z', 4).run();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement