vendredi 31 août 2018

How to create random value between two different sets of numbers

I am trying to generate a random character between the following two sets of unicode U+0020 to U+007E and U+00A0 to U+00FF. I have created the code to generate a value between U+00A0 to U+00FF but I also need my generator to include the values from U+00A0 to U+00FF, how is this possible? Any help is greatly appreciated, here is what I have so far. (P.S. I am using seed for testing). For example instead of just trying to create a integer between 1-10, I would like to know how to create a random number that could either be between 1-10 or 50-100.

  private static char random(){
        long seed = 1776;
        Random number = new Random(seed);
        int randomNumber = number.nextInt(126) + 32;
        char a = (char) randomNumber;
        return a;
    }




Aucun commentaire:

Enregistrer un commentaire