• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Operators Doubt

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Regards,
Hardik.S.Raja
 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic