File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Operators Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operators Doubt" Watch "Operators Doubt" New topic

Operators Doubt

Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
The below is a Two Minute Drill from chapter 4, Operator (K & B Book)
Page 300

> Increment/Decrement Operators

In any expression, both operands are fully evaluated before the operator
is applied.

Can anyone explain the above statement with an example.
Any suggestions are welcome.

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
ok ,explanation for this is here,shown below may be it helps you to some extent.

Evaluation Order

In Java, the order of evaluation of operands in an expression is fixed. All operands are evaluated from left to right. The order of execution of the operations may be completely different. For example:

int [] a = {5, 5};
int b = 1;
a[b] = b = 10;
In this example, on line 3 the a[b] operand is evaluated to a[1] because at that moment b equaled 1. Next b is evaluated to 1 again. Finally, 10 is evaluated simply as the constant 10. After the operands are evaluated, the assignment operations take place. Assignment is a right to left operation, so b is assigned 10 and then a[1] is assigned the value of b, which is 10.
I agree. Here's the link:
subject: Operators Doubt
jQuery in Action, 3rd edition