why my method toString returns 0?I have to concat an integer-generated random into a String and when I print the result it's always 0.What should I do?
class Cozi:
public String toString(){
String concat="";
Clienti ob = new Clienti();
for(int i=1;i<=Clienti.getNrClienti();i++){
concat=" <"+ob.getRandomInt2()+">";
System.out.print(concat);
}
return concat;
}
class Clienti:
public int serviceTime(){
System.out.print("\n");
Random randomServ = new Random();
for (int idx = 1; idx <= nrClienti; ++idx){
randomInt2 = randomServ.nextInt(maxServ);
System.out.println("Generated : " + randomInt2);
}
return randomInt2;
}
!here I have also the methods get and set randomInt2.
Aucun commentaire:
Enregistrer un commentaire