Ravi Singh
asked on
++ operator
Hi,
whats the difference between doing:
example:
int len = 0;
array[++len] = "hello";
array[len++] = "bye";
Using the incrementing operator as a prefix or postfix, is it effectively the same thing?
I looked at the official java tutorial and it says:
++ op++ Increments op by 1; evaluates to the value of op before it was incremented
++ ++op Increments op by 1; evaluates to the value of op after it was incremented
Don't understand what it means by "evaluates to the value of op before it was incremented". Can someone explain it in terms of my example above. And also, is this what people mean by 'efficient' programming, i.e. putting what could be two statements into one.
Cheers - Zephyr.
whats the difference between doing:
example:
int len = 0;
array[++len] = "hello";
array[len++] = "bye";
Using the incrementing operator as a prefix or postfix, is it effectively the same thing?
I looked at the official java tutorial and it says:
++ op++ Increments op by 1; evaluates to the value of op before it was incremented
++ ++op Increments op by 1; evaluates to the value of op after it was incremented
Don't understand what it means by "evaluates to the value of op before it was incremented". Can someone explain it in terms of my example above. And also, is this what people mean by 'efficient' programming, i.e. putting what could be two statements into one.
Cheers - Zephyr.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER