mardi 24 février 2015

cannot instantiate the type random [duplicate]


This question already has an answer here:




Im trying to create a random character generator but I keep getting the error "Cannot instantiate the type Random" why is this?


Here is the code:



private static char randomChar(){
Random rand = new Random(); // This is obviously the error
char c = (char)((rand.nextInt()*26)+'a');

return c;
}




Aucun commentaire:

Enregistrer un commentaire