Java Generate Next Alphanumeric Number
One digit number have 10 values, but if use alphabet then number value increase 26 times. Here use 5 digit value and if use only numbers then values count goto One Lakh (105 = 1,00,000) and add alphabet then value count goto more than Six Crore (10 Number + 26 Alphabet, 365 = 6,0466176)
"One digit values count in number have 10 and in alphabet have 26."
–  September 11th, 2018
import java.util.Arrays; import java.util.List;   public class NextValue {     static List<Character> list = Arrays.asList(     '0','1','2','3','4','5','6','7','8','9',     'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');     public static void main(String[] args) {       String num = "00000";       for(int i = 1; i <= 100; i++) {       num = nextNum(num);       System.out.println(num);     }     }     static String nextNum(String num) {       String dbnum = num;     String nextSeq = null;       if(dbnum.length() == 5) {       Character idx4 = dbnum.charAt(4);       Character idx3 = dbnum.charAt(3);       Character idx2 = dbnum.charAt(2);       Character idx1 = dbnum.charAt(1);       Character idx0 = dbnum.charAt(0);         if(list.indexOf(idx4) != 35) {           idx4 = list.get(list.indexOf(idx4) + 1);         } else if(list.indexOf(idx3) != 35) {           idx3 = list.get(list.indexOf(idx3) + 1);         idx4 = list.get(0);         } else if(list.indexOf(idx2) != 35) {           idx2 = list.get(list.indexOf(idx2) + 1);         idx3 = list.get(0);         idx4 = list.get(0);         } else if(list.indexOf(idx1) != 35) {           idx1 = list.get(list.indexOf(idx1) + 1);         idx2 = list.get(0);         idx3 = list.get(0);         idx4 = list.get(0);         } else if(list.indexOf(idx0) != 35) {           idx0 = list.get(list.indexOf(idx0) + 1);         idx1 = list.get(0);         idx2 = list.get(0);         idx3 = list.get(0);         idx4 = list.get(0);         }         nextSeq = "" + idx0 + idx1 + idx2 + idx3 + idx4;       }       return nextSeq;     }   }
Download Source Code