Okay so I want to create a for loop that assigns variables with each increment of i
. This is what I have, but it doesn't work due to a type mismatch:
int i;
String d;
for(i = 5; i > 0; i--){
String.valueOf(i);
d = i;
d = reader.readLine();
System.out.println(d);
}
So the error that I get right now is "type mismatch" when setting d = i
. Obviously I get the error due to d
not being an int but a String, but I thought String.valueOf(i)
was supposed to convert i
to a String? I must have misunderstood this. What am I doing wrong in this or what is another way to do this?