This program generates 50 random numbers between 1 to 100 and the output are written in the fileresult.txt .
FileWriter outputChar = new FileWriter(new File ("fileresult.txt"));
Random random = new Random();
for(int i = 1 ; i <= 50 ; i++){
int min = 1;
int max = 100;
int number = random.nextInt(max - min + 1) + min;
outputChar.write(number);
}
outputChar.close();
The problem is the output are not integer values, but many Chinese characters instead. Why does this happen?
Aucun commentaire:
Enregistrer un commentaire