Vel Vel - 4 years ago 790
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download