jeudi 31 mai 2018

Explaining a switch with random generated number within a specified range, probability of getting the range

Can someone explain how this fragment of code works?

    int rand = ThreadLocalRandom.current().nextInt(0,10);
    switch (rand)
    {
        case 0: return 2;
        case 1: return 1;
        case 2: return 1;
        default: return 0;
    }

Thanks!




Aucun commentaire:

Enregistrer un commentaire