mercredi 28 décembre 2016

how can i use the i variable outside the for loop?

I want to use the value of 'i' in a certain point, like in the example below. What i have tried to do didnt work, what else can i do?

 int i =1;
 int r;


for(i=1;i<=100;i++){

num = reader.nextInt();

if (num == 55){
    r=i;
}
System.out.println(" 55 was typed in when i was equals to: "+r);

Aucun commentaire:

Enregistrer un commentaire