Vel Vel - 11 months ago 239
Java Question

Java expressions

I am trying to understand this code in Java 7 environment,

int T = getIntVal();
while (T--> 0) {
// do stuff here

T is not modified within the while loop. Can someone explain this code?


what confuses you is that there is no whitespace between the T-- and the >, so you might think there's a --> operator.
looking like this:

while (T-- > 0) {


It makes more sense, in every loop you decrease T by one