samedi 11 novembre 2023

Implement nextBoolean using nextInt

Can we safely implement nextBoolean using nextInt in java?

for example as below,

   public static boolean nextBoolean(Random random) {
        return random.nextInt(2) == 0;
    }



Aucun commentaire:

Enregistrer un commentaire