How do you use the FOR <-- Loop in java !
for(int i = 0; i <10; i++)
you mean the trick? int i = 10; while (0 <-- i) { // Do stuff. }
yea
like for (int i=0; i<=something; i++); { }
Shouldn't add a semicolon between the end of the for statement and the opening brace.
yea , but like what does i++ mean
each time it goes through loop i value is increased by 1 so you could write i = i + 1 or i+=1
ohhhhhh ! ok
thanks ! i hate comp science i dun even know why i took it ! LOL
The ++ operator in C and C derived languages is the auto increment operator. -- is the auto decrement operator. If you have an int(eger) variable c, ++c would increment c before it is evaluated. c++ would evaluate the value of c and then increment it. They're actually called pre/post auto increment/decrement operators.
what do you mean increment before it is evaluated
{ int c = 9; printf( "%d\n", ++c ); /* will print 10 */ printf( "%d\n", c++); /* will print 10 */ printf( "%d\n", c ); /* will print 11 */ }
also, something like i = ++i + i++ - --i - i-- would be undefined behavior :-P
Join our real-time social learning platform and learn together with your friends!