dimanche 19 février 2017

java inheriting random class and the caller

I have the following code regarding inherting the Random class but I cannot figure out what is happening.

import java.util.Random;

public class Chance extends Random{

    public int throwDie(){      
        return (1 + nextInt(6));
    }
}

in the throuDie method, the "nextInt" method has no caller. I do not understand how can it run like this. I did not even create a Chance object nor a Random object.

can someone explain?

Thank you




Aucun commentaire:

Enregistrer un commentaire