I need to take a random element from an array of char
s
- C for hearts
- Q for diamonds
- F for clubs
- P for spades
Random casuale = new Random()
char[] arraySuits = {'c', 'c', 'c', 'q', 'q', 'q', 'f', 'f', 'f', 'p', 'p', 'p',};
location1S=casuale.next(arraySuits.length);
location2S=casuale.next(arraySuits.length);
There are two errors:
- Type mismatch: cannot convert from
int
tochar
- The method
next(int)
from the typeRandom
is not visible
The errors are both at casuale.next(arraySuits.length)
but I don't know how to fix it.
Aucun commentaire:
Enregistrer un commentaire