[Solved] Random seed generator


When asking for code to be reviewed, you should post it here. But regardless of that, there are much more efficient ways to generate a random character.

One such way would be to generate a random character between 65 and 90, the decimal values for A-Z on the ASCII table. And then, just cast the value as a char to get the actual letter corresponding to the number. However, you say that you want the number 9 to also be included, so you can extend this to 91, and if you get 91, which on the ASCII table is [, add the number 9 to your string instead of that.

This code accomplishes that quite easily:

String mySeed = "";
      for(int i=0; i<81; i++)
      {
         int randomNum = (int)(Math.random()*27) + 65;
         if(randomNum==91)
            mySeed+="9";
         else
            mySeed+=(char)randomNum;
      }
      System.out.println(mySeed);

And, as mentioned by @O.O. you can look at generating a secure random number here.

solved Random seed generator