dimanche 28 juin 2015

Using randoms and super

How would I call a Random from java.util.Random into a supertype constructor?

For example

Random rand = new Random();
int randomValue = rand.nextInt(10) + 5;

public Something() 
{
    super(randomValue);
    //Over Things
}

When I try this the compiler says I "cannot reference randomValue before supertype constructor has been called".




Aucun commentaire:

Enregistrer un commentaire