A voir également:
- Random java
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel - Télécharger - Jeux vidéo
- Eclipse java - Télécharger - Langages
- Java apk - Télécharger - Langages
- Waptrick java voiture - Télécharger - Jeux vidéo
3 réponses
Pour prendre la date en court, il faut juste utiliser Date date=new Date(); .
Si ta boucle s'execute en moins d'une seconde, la valeur nbrPourInitialiser sera toujours la même.
Je te conseil de sortir de ta boucle l'initialisation du random.
Plus ça rate, plus on a de chances que ça marche.
Si ta boucle s'execute en moins d'une seconde, la valeur nbrPourInitialiser sera toujours la même.
Je te conseil de sortir de ta boucle l'initialisation du random.
public void actionPerformed(ActionEvent evt){ Random r = new Random(); Date date=new Date(); int nbrPourInitialiser=date.getSeconds(); r.setSeed((long)nbrPourInitialiser); System.out.println(nbrPourInitialiser); for(int i=0;i<6;i++){ int n= r.nextInt(49); String s =""+n; boutons[i].setText(s); } }
Plus ça rate, plus on a de chances que ça marche.
bonjour,
j'ai un probleme dans mon pg c ke quand j'affiche ma matrice de vector il me l'affiche aléatoirement c ca ke je veuw faire mais ya des objets ki manquent a chaque fois .
voici le bout de mon pg
x=r1.nextInt(10);y=r2.nextInt(10);
while ((compt<10) && (tab[x][y]== null)){
Vector fourmi=new Vector();
fourmi.addElement(new Integer(compt));
tab[x][y]=fourmi;compt=compt+1;
x=r3.nextInt(10);y=r4.nextInt(10);
}
for(int i=0;i<10 ;i++){
for(int j=0;j<10;j++){
System.out.println(tab[i][j]);
j'ai un probleme dans mon pg c ke quand j'affiche ma matrice de vector il me l'affiche aléatoirement c ca ke je veuw faire mais ya des objets ki manquent a chaque fois .
voici le bout de mon pg
x=r1.nextInt(10);y=r2.nextInt(10);
while ((compt<10) && (tab[x][y]== null)){
Vector fourmi=new Vector();
fourmi.addElement(new Integer(compt));
tab[x][y]=fourmi;compt=compt+1;
x=r3.nextInt(10);y=r4.nextInt(10);
}
for(int i=0;i<10 ;i++){
for(int j=0;j<10;j++){
System.out.println(tab[i][j]);