I have a puzzle on my hands: on Item#3 of the attached java file the 'a' is jumping to 102 when it should be at 101. The output file (Word) is also attached to this e-mail. Thank you for your help. Charles.
Charles, After step 1 a equals 100 and b equals 101. But in step 3 b gets incremented to 102 before the new result is assigned to a. Make sense? [ February 27, 2004: Message edited by: Howard Kushner ]
Howard Kushner<br />IBM Certified Enterprise Developer - WebSphere Studio Application Developer V5.0<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - Web Services with WebSphere Studio V5.1<br /><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1931182108/" target="_blank" rel="nofollow">Developing J2EE Applications with WebSphere Studio</a> my Certification Study Guide for IBM Test 287
One interesting thing you might want to figure out is:
First, expand that nasty little += operator. Keep in mind += (like =) is right-associative, so when it is expanded the i is replaced with the value of i before any other evaluation takes place:
(Another code snippet that you might find helpful to run is:
The result after this snippet runs? x is { 5, 0 } and i is 0.) Because the + operator is right associative, the right operand is evaluated first. The explicitly paranthesized version of the above statement is:
So the expression is evaluated (steps explicitly shown):
Voila. The thing to keep in mind is that with left-associative operators like = and +=, the leftmost operands are evaluated first and all expressions are replaced. With right-associative operators like +, the rightmost operands are evaluated first and all expressions replaced. Oh yea, I couldn't leave without this little gem (language lawyers will find this delightful). The following two statements are both compilable and equivalent:
Boggles the mind, don't it? sev [ March 01, 2004: Message edited by: sever oon ]
Thank you sever for your interesting posting re. += bugger. I certainly will try it out. I have another question re. Increment & Decrement including prefix and postfix. I tried to make a truth table and I wonder if I got it right or whether there are mistakes in it. So I sending you as attachment the following documents:
I am sorry, Sever, but it looks like the Excel spreadsheet is all screwed up. Thank you for your help. Charles.
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners