Tel Mark
20-09-2012, 12:48
Probabilmente mi sto perdendo in un bicchere d'acqua, ma vabbè...
il metodo nextInt() e nextInt(int n) della classe Random restituiscono un intero casuale (maggiore di zero e minore di n nel secondo caso) e fin qui tutto ok
Random gen = new Random();
int n = gen.nextInt(100);
Vi risparmio il resto del programma, che mi serve solo per provare qualche metodo di questa classe.
Il compilatore restituisce il seguente errore:
guerro@ubuntu-U36SG:~$ javac random.java
random.java:10: error: cannot find symbol
n = gen.nextInt(100);
^
symbol: method nextInt(int)
location: variable gen of type Random
1 error
Penso sia un problema di import
se metto
import java.util.Random;
Mi restituisce
error: Random is already defined in this compilation unit
import java.util.Random;
Boh... suggerimenti?
il metodo nextInt() e nextInt(int n) della classe Random restituiscono un intero casuale (maggiore di zero e minore di n nel secondo caso) e fin qui tutto ok
Random gen = new Random();
int n = gen.nextInt(100);
Vi risparmio il resto del programma, che mi serve solo per provare qualche metodo di questa classe.
Il compilatore restituisce il seguente errore:
guerro@ubuntu-U36SG:~$ javac random.java
random.java:10: error: cannot find symbol
n = gen.nextInt(100);
^
symbol: method nextInt(int)
location: variable gen of type Random
1 error
Penso sia un problema di import
se metto
import java.util.Random;
Mi restituisce
error: Random is already defined in this compilation unit
import java.util.Random;
Boh... suggerimenti?