This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi Vineela, 1.) every call to the m method is evaluated, this results in: m( 1 + 2 % 3 * 4 ) 2.) the expression is evaluated from left to right and following the precendence rules which looks like this with brackets: m1(1 + ((2 % 3) * 4)) and results in: m1(9) the whole thing gives us: 1,2,3,4,9, HTH, greetings, Gian Franco
"Eppur si muove!"
Joined: Dec 20, 2003
Hi Gian, But A/c to Operator Precedence '*' is having highest precedence than '%'.So, i think the exp should be evaluated as 1+(2%(3*4)) resulting in a value of 3. Am i going wrong anywhere? Pls correct me. Regards Vineela
Joined: Dec 16, 2003
Hi Vineela, the operators * and % have the same precedence and it depends on which one comes first when read from left to right. So the following: m(m(1) + m(4) * m(2) % m(3));
gives another result than m(m(1) + m(2) % m(3) * m(4));