Link to home
Start Free TrialLog in
Avatar of Ravi Singh
Ravi SinghFlag for United Kingdom of Great Britain and Northern Ireland

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.
ASKER CERTIFIED SOLUTION
Avatar of petmagdy
petmagdy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ravi Singh

ASKER

thanks for clearing that up.